mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added support for the truncate table with restart identity. Fixes #2538
This commit is contained in:
parent
56e2af9efc
commit
d38f520805
@ -74,8 +74,9 @@ following options (in alphabetical order):
|
||||
+-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
||||
| *Trigger(s)* | Click to *Disable* or *Enable* trigger(s) for the currently selected table. Options are displayed on the flyout menu. |
|
||||
+-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
||||
| *Truncate* | Click to remove all rows from a table (*Truncate*) or to remove all rows from a table and its child tables |
|
||||
| | (*Truncate Cascade*). Options are displayed on the flyout menu. |
|
||||
| *Truncate* | Click to remove all rows from a table (*Truncate*), to remove all rows from a table and its child tables |
|
||||
| | (*Truncate Cascade*) or to remove all rows from a table and automatically restart sequences owned by columns |
|
||||
| | (*Truncate Restart Identity*). Options are displayed on the flyout menu. |
|
||||
+-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
||||
| *View Data* | Click to access a context menu that provides several options for viewing data (see below). |
|
||||
+-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
||||
|
@ -9,6 +9,7 @@ This release contains a number of bug fixes and new features since the release o
|
||||
New features
|
||||
************
|
||||
|
||||
| `Issue #2538 <https://redmine.postgresql.org/issues/2538>`_ - Added support for the truncate table with restart identity.
|
||||
| `Issue #4264 <https://redmine.postgresql.org/issues/4264>`_ - Make code folding case insensitive in the code mirror.
|
||||
| `Issue #4629 <https://redmine.postgresql.org/issues/4629>`_ - Added database and server information on the Maintenance process watcher dialog.
|
||||
| `Issue #6495 <https://redmine.postgresql.org/issues/6495>`_ - Allow the referenced table to be the same as the local table in one to many relationship for ERD Tool.
|
||||
|
@ -89,6 +89,11 @@ define('pgadmin.node.table', [
|
||||
applies: ['object', 'context'], callback: 'truncate_table_cascade',
|
||||
category: gettext('Truncate'), priority: 3, label: gettext('Truncate Cascade'),
|
||||
icon: 'fa fa-eraser', enable : 'canCreate',
|
||||
},{
|
||||
name: 'truncate_table_identity', node: 'table', module: this,
|
||||
applies: ['object', 'context'], callback: 'truncate_table_identity',
|
||||
category: gettext('Truncate'), priority: 3, label: gettext('Truncate Restart Identity'),
|
||||
icon: 'fa fa-eraser', enable : 'canCreate',
|
||||
},{
|
||||
// To enable/disable all triggers for the table
|
||||
name: 'enable_all_triggers', node: 'table', module: this,
|
||||
@ -159,6 +164,10 @@ define('pgadmin.node.table', [
|
||||
var params = {'cascade': true };
|
||||
this.callbacks.truncate.apply(this, [args, params]);
|
||||
},
|
||||
truncate_table_identity: function(args) {
|
||||
var params = {'identity': true };
|
||||
this.callbacks.truncate.apply(this, [args, params]);
|
||||
},
|
||||
truncate: function(args, params) {
|
||||
var input = args || {},
|
||||
obj = this,
|
||||
|
@ -1 +1 @@
|
||||
TRUNCATE TABLE {{conn|qtIdent(data.schema, data.name)}}{% if cascade %} CASCADE{% endif %};
|
||||
TRUNCATE TABLE {{conn|qtIdent(data.schema, data.name)}}{% if identity %} RESTART IDENTITY{% endif %}{% if cascade %} CASCADE{% endif %};
|
||||
|
@ -1897,13 +1897,15 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
|
||||
request.data, encoding='utf-8'
|
||||
)
|
||||
# Convert str 'true' to boolean type
|
||||
is_cascade = json.loads(data['cascade'])
|
||||
is_cascade = json.loads(data.get('cascade') or 'false')
|
||||
is_identity = json.loads(data.get('identity') or 'false')
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
sql = render_template("/".join([self.table_template_path,
|
||||
'truncate.sql']),
|
||||
data=data, cascade=is_cascade)
|
||||
data=data, cascade=is_cascade,
|
||||
identity=is_identity)
|
||||
status, res = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
@ -163,7 +163,7 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
|
||||
)
|
||||
else:
|
||||
self.assertEqual(
|
||||
command, vacuum_details + "\nRunning Query:\nVACUUM VERBOSE;"
|
||||
command, vacuum_details + "\nRunning Query:\nVACUUM VERBOSE"
|
||||
" public." + self.table_name + ";")
|
||||
|
||||
test_gui_helper.close_process_watcher(self)
|
||||
|
Loading…
Reference in New Issue
Block a user