mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-15 01:43:45 -06:00
Fixed internal server error when clicking on Triggers -> 'Enable All' for partitions. Fixes #5052
This commit is contained in:
parent
7d4ddc3910
commit
073d90c4a6
@ -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 #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 #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 #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.
|
||||
|
@ -220,8 +220,8 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
'sql': [{'get': 'sql'}],
|
||||
'msql': [{'get': 'msql'}, {}],
|
||||
'detach': [{'put': 'detach'}],
|
||||
'truncate': [{'put': 'truncate'}]
|
||||
|
||||
'truncate': [{'put': 'truncate'}],
|
||||
'set_trigger': [{'put': 'enable_disable_triggers'}]
|
||||
})
|
||||
|
||||
# Schema Diff: Keys to ignore while comparing
|
||||
@ -772,6 +772,59 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
except Exception as 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):
|
||||
"""
|
||||
This function returns the DDL/DML statements based on the
|
||||
|
@ -119,12 +119,12 @@ function(
|
||||
callbacks: {
|
||||
/* Enable trigger(s) on table */
|
||||
enable_triggers_on_table: function(args) {
|
||||
var params = {'enable': true };
|
||||
var params = {'is_enable_trigger': 'O'};
|
||||
this.callbacks.set_triggers.apply(this, [args, params]);
|
||||
},
|
||||
/* Disable trigger(s) on table */
|
||||
disable_triggers_on_table: function(args) {
|
||||
var params = {'enable': false };
|
||||
var params = {'is_enable_trigger': 'D'};
|
||||
this.callbacks.set_triggers.apply(this, [args, params]);
|
||||
},
|
||||
set_triggers: function(args, params) {
|
||||
|
Loading…
Reference in New Issue
Block a user