diff --git a/docs/en_US/images/rule_commands.png b/docs/en_US/images/rule_commands.png new file mode 100644 index 000000000..3c20f6390 Binary files /dev/null and b/docs/en_US/images/rule_commands.png differ diff --git a/docs/en_US/images/rule_condition.png b/docs/en_US/images/rule_condition.png new file mode 100644 index 000000000..a52cb152e Binary files /dev/null and b/docs/en_US/images/rule_condition.png differ diff --git a/docs/en_US/images/rule_definition.png b/docs/en_US/images/rule_definition.png old mode 100755 new mode 100644 index 26114b675..87b111046 Binary files a/docs/en_US/images/rule_definition.png and b/docs/en_US/images/rule_definition.png differ diff --git a/docs/en_US/images/rule_general.png b/docs/en_US/images/rule_general.png old mode 100755 new mode 100644 index a73c1f687..a6ae46038 Binary files a/docs/en_US/images/rule_general.png and b/docs/en_US/images/rule_general.png differ diff --git a/docs/en_US/images/rule_sql.png b/docs/en_US/images/rule_sql.png old mode 100755 new mode 100644 index d64a7da97..c0a2c6e34 Binary files a/docs/en_US/images/rule_sql.png and b/docs/en_US/images/rule_sql.png differ diff --git a/docs/en_US/release_notes_4_12.rst b/docs/en_US/release_notes_4_12.rst index f0410304d..13cf81441 100644 --- a/docs/en_US/release_notes_4_12.rst +++ b/docs/en_US/release_notes_4_12.rst @@ -47,4 +47,5 @@ Bug fixes | `Issue #4578 `_ - Ensure enable trigger menu should be visible when trigger is disabled. | `Issue #4581 `_ - Ensure the comment on a Primary Key constraint can be edited under the Table node. | `Issue #4582 `_ - Fix console error when changing kind(SQL/BATCH) for pgAgent job step. -| `Issue #4585 `_ - Fix double click issue to expand the contents of a cell if the resultset was not editable. \ No newline at end of file +| `Issue #4585 `_ - Fix double click issue to expand the contents of a cell if the resultset was not editable. +| `Issue #4586 `_ - Fix generation of reverse engineered SQL for Rules. \ No newline at end of file diff --git a/docs/en_US/rule_dialog.rst b/docs/en_US/rule_dialog.rst index 8eb7a679b..093b30653 100644 --- a/docs/en_US/rule_dialog.rst +++ b/docs/en_US/rule_dialog.rst @@ -9,8 +9,8 @@ A PostgreSQL rule allows you to define an additional action that will be performed when a SELECT, INSERT, UPDATE, or DELETE is performed against a table. The *Rule* dialog organizes the development of a rule through the *General*, -and *Definition* tabs. The *SQL* tab displays the SQL code generated by dialog -selections. +*Definition*, *Condition*, *Commands* tabs. The *SQL* tab displays the SQL code +generated by dialog selections. .. image:: images/rule_general.png :alt: Rule dialog general tab @@ -36,10 +36,22 @@ Use the fields in the *Definition* tab to write parameters: * Move the *Do Instead* switch to *Yes* indicate that the commands should be executed instead of the original command; if Do Instead specifies *No*, the rule will be invoked in addition to the original command. -* Specify a SQL conditional expression that returns a boolean value in the - *Condition* editor. -* Provide a command in the *Commands* editor that defines the action performed - by the rule. + +Click the *Condition* tab to continue. + +.. image:: images/rule_condition.png + :alt: Rule dialog condition tab + :align: center + +Specify a SQL conditional expression that returns a boolean value in the editor. + +Click the *Commands* tab to continue. + +.. image:: images/rule_commands.png + :alt: Rule dialog commands tab + :align: center + +Provide a command in the editor that defines the action performed by the rule. Click the *SQL* tab to continue. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js index b4b3c2b97..7d66d9116 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js @@ -180,13 +180,15 @@ define('pgadmin.node.rule', [ }, { id: 'condition', label: gettext('Condition'), - type: 'text', group: gettext('Definition'), - control: Backform.SqlFieldControl, + type: 'text', group: gettext('Condition'), + tabPanelCodeClass: 'sql-code-control', + control: Backform.SqlCodeControl, }, { id: 'statements', label: gettext('Commands'), - type: 'text', group: gettext('Definition'), - control: Backform.SqlFieldControl, + type: 'text', group: gettext('Commands'), + tabPanelCodeClass: 'sql-code-control', + control: Backform.SqlCodeControl, }, { id: 'system_rule', label: gettext('System rule?'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py index c61fe6734..af667f7b1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py @@ -423,7 +423,7 @@ def parse_rule_definition(res): instead = True if instead_data is not None else False # Parse data for condition - condition_match = re.search(r"(?:WHERE)\s+(.*)\s+(?:DO)", data_def) + condition_match = re.search(r"(?:WHERE)\s+([\s\S]*)\s+(?:DO)", data_def) condition_data = condition_match.group(1) \ if condition_match is not None else None condition = condition_data if condition_data is not None else ''