mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-07-29 15:53:54 -05:00
Fixed internal server error when clicking on Triggers -> 'Enable All' for partitions. Fixes #5052
This commit is contained in:
@@ -26,6 +26,7 @@ Bug fixes
|
|||||||
| `Issue #4279 <https://redmine.postgresql.org/issues/4279>`_ - Ensure that file browse "home" button should point to $HOME rather than /.
|
| `Issue #4279 <https://redmine.postgresql.org/issues/4279>`_ - Ensure that file browse "home" button should point to $HOME rather than /.
|
||||||
| `Issue #4840 <https://redmine.postgresql.org/issues/4840>`_ - Ensure that 'With OID' option should be disabled while taking backup of database server version 12 and above.
|
| `Issue #4840 <https://redmine.postgresql.org/issues/4840>`_ - Ensure that 'With OID' option should be disabled while taking backup of database server version 12 and above.
|
||||||
| `Issue #5001 <https://redmine.postgresql.org/issues/5001>`_ - Fixed invalid literal issue when removing the connection limit for the existing role.
|
| `Issue #5001 <https://redmine.postgresql.org/issues/5001>`_ - Fixed invalid literal issue when removing the connection limit for the existing role.
|
||||||
|
| `Issue #5052 <https://redmine.postgresql.org/issues/5052>`_ - Fixed internal server error when clicking on Triggers -> 'Enable All' for partitions.
|
||||||
| `Issue #5398 <https://redmine.postgresql.org/issues/5398>`_ - Fixed generated SQL issue for auto vacuum options.
|
| `Issue #5398 <https://redmine.postgresql.org/issues/5398>`_ - Fixed generated SQL issue for auto vacuum options.
|
||||||
| `Issue #5422 <https://redmine.postgresql.org/issues/5422>`_ - Ensure that the dependencies tab shows correct information for Synonyms.
|
| `Issue #5422 <https://redmine.postgresql.org/issues/5422>`_ - Ensure that the dependencies tab shows correct information for Synonyms.
|
||||||
| `Issue #5434 <https://redmine.postgresql.org/issues/5434>`_ - Fixed an issue where the newly added table is not alphabetically added to the tree.
|
| `Issue #5434 <https://redmine.postgresql.org/issues/5434>`_ - Fixed an issue where the newly added table is not alphabetically added to the tree.
|
||||||
|
|||||||
+55
-2
@@ -220,8 +220,8 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
|||||||
'sql': [{'get': 'sql'}],
|
'sql': [{'get': 'sql'}],
|
||||||
'msql': [{'get': 'msql'}, {}],
|
'msql': [{'get': 'msql'}, {}],
|
||||||
'detach': [{'put': 'detach'}],
|
'detach': [{'put': 'detach'}],
|
||||||
'truncate': [{'put': 'truncate'}]
|
'truncate': [{'put': 'truncate'}],
|
||||||
|
'set_trigger': [{'put': 'enable_disable_triggers'}]
|
||||||
})
|
})
|
||||||
|
|
||||||
# Schema Diff: Keys to ignore while comparing
|
# Schema Diff: Keys to ignore while comparing
|
||||||
@@ -772,6 +772,59 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return internal_server_error(errormsg=str(e))
|
return internal_server_error(errormsg=str(e))
|
||||||
|
|
||||||
|
@BaseTableView.check_precondition
|
||||||
|
def enable_disable_triggers(self, gid, sid, did, scid, tid, ptid):
|
||||||
|
"""
|
||||||
|
This function will enable/disable trigger(s) on the partition object
|
||||||
|
|
||||||
|
Args:
|
||||||
|
gid: Server Group ID
|
||||||
|
sid: Server ID
|
||||||
|
did: Database ID
|
||||||
|
scid: Schema ID
|
||||||
|
tid: Table ID
|
||||||
|
ptid: Partition Table ID
|
||||||
|
"""
|
||||||
|
data = request.form if request.form else json.loads(
|
||||||
|
request.data, encoding='utf-8'
|
||||||
|
)
|
||||||
|
# Convert str 'true' to boolean type
|
||||||
|
is_enable_trigger = data['is_enable_trigger']
|
||||||
|
|
||||||
|
try:
|
||||||
|
SQL = render_template(
|
||||||
|
"/".join([self.partition_template_path, 'properties.sql']),
|
||||||
|
did=did, scid=scid, tid=tid, ptid=ptid,
|
||||||
|
datlastsysoid=self.datlastsysoid
|
||||||
|
)
|
||||||
|
status, res = self.conn.execute_dict(SQL)
|
||||||
|
if not status:
|
||||||
|
return internal_server_error(errormsg=res)
|
||||||
|
data = res['rows'][0]
|
||||||
|
|
||||||
|
SQL = render_template(
|
||||||
|
"/".join([
|
||||||
|
self.table_template_path, 'enable_disable_trigger.sql'
|
||||||
|
]),
|
||||||
|
data=data, is_enable_trigger=is_enable_trigger
|
||||||
|
)
|
||||||
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
|
if not status:
|
||||||
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
|
return make_json_response(
|
||||||
|
success=1,
|
||||||
|
info=gettext("Trigger(s) have been disabled")
|
||||||
|
if is_enable_trigger == 'D'
|
||||||
|
else gettext("Trigger(s) have been enabled"),
|
||||||
|
data={
|
||||||
|
'id': ptid,
|
||||||
|
'scid': scid
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
return internal_server_error(errormsg=str(e))
|
||||||
|
|
||||||
def ddl_compare(self, **kwargs):
|
def ddl_compare(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
This function returns the DDL/DML statements based on the
|
This function returns the DDL/DML statements based on the
|
||||||
|
|||||||
+2
-2
@@ -119,12 +119,12 @@ function(
|
|||||||
callbacks: {
|
callbacks: {
|
||||||
/* Enable trigger(s) on table */
|
/* Enable trigger(s) on table */
|
||||||
enable_triggers_on_table: function(args) {
|
enable_triggers_on_table: function(args) {
|
||||||
var params = {'enable': true };
|
var params = {'is_enable_trigger': 'O'};
|
||||||
this.callbacks.set_triggers.apply(this, [args, params]);
|
this.callbacks.set_triggers.apply(this, [args, params]);
|
||||||
},
|
},
|
||||||
/* Disable trigger(s) on table */
|
/* Disable trigger(s) on table */
|
||||||
disable_triggers_on_table: function(args) {
|
disable_triggers_on_table: function(args) {
|
||||||
var params = {'enable': false };
|
var params = {'is_enable_trigger': 'D'};
|
||||||
this.callbacks.set_triggers.apply(this, [args, params]);
|
this.callbacks.set_triggers.apply(this, [args, params]);
|
||||||
},
|
},
|
||||||
set_triggers: function(args, params) {
|
set_triggers: function(args, params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user