Add DROP SQL for foreign keys in SQL generated by ERD when using WITH DROP option. #5770

This commit is contained in:
Aditya Toshniwal
2023-11-16 16:55:26 +05:30
parent cc239149ba
commit c9db4a0d16
11 changed files with 39 additions and 148 deletions

View File

@@ -34,6 +34,7 @@ Bug fixes
********* *********
| `Issue #2986 <https://github.com/pgadmin-org/pgadmin4/issues/2986>`_ - Fix an issue where the scroll position of panels was not remembered on Firefox. | `Issue #2986 <https://github.com/pgadmin-org/pgadmin4/issues/2986>`_ - Fix an issue where the scroll position of panels was not remembered on Firefox.
| `Issue #5770 <https://github.com/pgadmin-org/pgadmin4/issues/5770>`_ - Add DROP SQL for foreign keys in SQL generated by ERD when using WITH DROP option.
| `Issue #5807 <https://github.com/pgadmin-org/pgadmin4/issues/5807>`_ - Fixed an issue where psql was not taking the role used to connect in server properties. | `Issue #5807 <https://github.com/pgadmin-org/pgadmin4/issues/5807>`_ - Fixed an issue where psql was not taking the role used to connect in server properties.
| `Issue #6459 <https://github.com/pgadmin-org/pgadmin4/issues/6459>`_ - Fix the sorting of size on the statistics panel. | `Issue #6459 <https://github.com/pgadmin-org/pgadmin4/issues/6459>`_ - Fix the sorting of size on the statistics panel.
| `Issue #6487 <https://github.com/pgadmin-org/pgadmin4/issues/6487>`_ - Fixed restoration of query tool database connection after dropping and re-creating the database with the same name. | `Issue #6487 <https://github.com/pgadmin-org/pgadmin4/issues/6487>`_ - Fixed restoration of query tool database connection after dropping and re-creating the database with the same name.
@@ -48,5 +49,6 @@ Bug fixes
| `Issue #6877 <https://github.com/pgadmin-org/pgadmin4/issues/6877>`_ - Remove the max length of 255 from password exec command in server configuration dialog. | `Issue #6877 <https://github.com/pgadmin-org/pgadmin4/issues/6877>`_ - Remove the max length of 255 from password exec command in server configuration dialog.
| `Issue #6884 <https://github.com/pgadmin-org/pgadmin4/issues/6884>`_ - Remove gettext from empty strings in the title of the storage graph. | `Issue #6884 <https://github.com/pgadmin-org/pgadmin4/issues/6884>`_ - Remove gettext from empty strings in the title of the storage graph.
| `Issue #6902 <https://github.com/pgadmin-org/pgadmin4/issues/6902>`_ - Fixed an issue where the change server password is not working in desktop mode. | `Issue #6902 <https://github.com/pgadmin-org/pgadmin4/issues/6902>`_ - Fixed an issue where the change server password is not working in desktop mode.
| `Issue #6904 <https://github.com/pgadmin-org/pgadmin4/issues/6904>`_ - Fix a crash issue occurring when debugging a function with arguments when using pgAdmin with external config database.
| `Issue #6920 <https://github.com/pgadmin-org/pgadmin4/issues/6920>`_ - Fix an issue in ERD tool where SQL generated is missing columns for the table. | `Issue #6920 <https://github.com/pgadmin-org/pgadmin4/issues/6920>`_ - Fix an issue in ERD tool where SQL generated is missing columns for the table.
| `Issue #6934 <https://github.com/pgadmin-org/pgadmin4/issues/6934>`_ - Clear the password field in the config database on clear saved server password. | `Issue #6934 <https://github.com/pgadmin-org/pgadmin4/issues/6934>`_ - Clear the password field in the config database on clear saved server password.

View File

@@ -159,6 +159,21 @@ def get_parent(conn, tid, template_path=None):
return schema, table return schema, table
@get_template_path
def get_delete_sql(conn, fk_data, template_path=None):
"""
This function will generate sql from model data.
:param conn: Connection Object
:param data: data
:param template_path: Template Path
:return:
"""
return render_template("/".join(
[template_path,
'delete.sql']),
data=fk_data, conn=conn).strip('\n')
def _get_sql_for_delete_fk_constraint(data, constraint, sql, template_path, def _get_sql_for_delete_fk_constraint(data, constraint, sql, template_path,
conn): conn):
""" """

View File

@@ -116,8 +116,6 @@ export default class RoleSchema extends BaseUISchema {
{ {
id: 'rolcanlogin', label: gettext('Can login?'), id: 'rolcanlogin', label: gettext('Can login?'),
type: 'switch', type: 'switch',
controlLabelClassName: 'control-label pg-el-sm-4 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-8 pg-el-12',
group: gettext('Privileges'), group: gettext('Privileges'),
disabled: obj.readOnly, disabled: obj.readOnly,
}, },
@@ -134,8 +132,6 @@ export default class RoleSchema extends BaseUISchema {
id: 'rolcreaterole', label: gettext('Create roles?'), id: 'rolcreaterole', label: gettext('Create roles?'),
group: gettext('Privileges'), group: gettext('Privileges'),
type: 'switch', type: 'switch',
controlLabelClassName: 'control-label pg-el-sm-4 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-8 pg-el-12',
disabled: obj.readOnly, disabled: obj.readOnly,
}, },
{ {
@@ -160,16 +156,12 @@ export default class RoleSchema extends BaseUISchema {
id: 'rolinherit', group: gettext('Privileges'), id: 'rolinherit', group: gettext('Privileges'),
label: gettext('Inherit rights from the parent roles?'), label: gettext('Inherit rights from the parent roles?'),
type: 'switch', type: 'switch',
controlLabelClassName: 'control-label pg-el-sm-4 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-8 pg-el-12',
disabled: obj.readOnly, disabled: obj.readOnly,
}, },
{ {
id: 'rolreplication', group: gettext('Privileges'), id: 'rolreplication', group: gettext('Privileges'),
label: gettext('Can initiate streaming replication and backups?'), label: gettext('Can initiate streaming replication and backups?'),
type: 'switch', type: 'switch',
controlLabelClassName: 'control-label pg-el-sm-4 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-8 pg-el-12',
min_version: 90100, min_version: 90100,
disabled: obj.readOnly, disabled: obj.readOnly,
}, },

View File

@@ -43,9 +43,9 @@ define('pgadmin.node.server', [
}, },
title: function(d, action) { title: function(d, action) {
if(action == 'create') { if(action == 'create') {
return gettext('Register - %s', this.label); return gettext('Register - %s', this._label);
} }
return d.label??''; return d._label??'';
}, },
Init: function() { Init: function() {
/* Avoid multiple registration of same menus */ /* Avoid multiple registration of same menus */

View File

@@ -90,9 +90,9 @@ define('pgadmin.browser.node', [
title: function(d, action) { title: function(d, action) {
if(action == 'create') { if(action == 'create') {
return gettext('Create - %s', this.label); return gettext('Create - %s', this._label);
} }
return d.label??''; return d._label??'';
}, },
hasId: true, hasId: true,
/////// ///////

View File

@@ -77,6 +77,9 @@ export default function rcdockOverride(theme) {
color: theme.palette.text.primary, color: theme.palette.text.primary,
} }
}, },
'& .dock-nav-more': {
display: 'none',
}
}, },
'& .dock-tabpane': { '& .dock-tabpane': {
backgroundColor: theme.palette.background.default, backgroundColor: theme.palette.background.default,

View File

@@ -24,38 +24,6 @@ export function parseShortcutValue(obj) {
return shortcut; return shortcut;
} }
export function findAndSetFocus(container) {
if (container.length == 0) {
return;
}
setTimeout(function() {
let first_el = container
.find('button.fa-plus:first');
/* Adding the tabindex condition makes sure that
* when testing accessibility it works consistently across all
* browser. For eg, in safari focus() works only when element has
* tabindex="0", whereas in Chrome it works in any case
*/
if (first_el.length == 0) {
first_el = container
.find(`
.pgadmin-controls:first .btn:not(.toggle),
.pgadmin-controls:first,
.ajs-commands:first,
.CodeMirror-scroll,
.pgadmin-wizard`)
.find('*[tabindex]:not([tabindex="-1"]),input:enabled');
}
if(first_el.length > 0) {
first_el[0].focus();
} else {
container[0].focus();
}
}, 200);
}
export function getEpoch(inp_date) { export function getEpoch(inp_date) {
let date_obj = inp_date ? inp_date : new Date(); let date_obj = inp_date ? inp_date : new Date();
return parseInt(date_obj.getTime()/1000); return parseInt(date_obj.getTime()/1000);

View File

@@ -18,21 +18,6 @@
min-height: 100% !important; min-height: 100% !important;
} }
/*
* Remove border right from "CodeMirror-gutters"
* class because its height doesn't increase
* with every new line added, instead add border
* right to ".CodeMirror-linenumber" class which
* adds a new div for every new line added
*/
.sql_field_layout .CodeMirror-gutters {
border-right: none;
}
.sql_field_layout .CodeMirror-linenumber {
border-right: 1px solid $color-gray-lighter;
}
/* class to disable Codemirror editor */ /* class to disable Codemirror editor */
.cm_disabled { .cm_disabled {
background: $input-disabled-bg; background: $input-disabled-bg;
@@ -100,6 +85,8 @@
.CodeMirror-linenumber { .CodeMirror-linenumber {
color: $color-fg; color: $color-fg;
font-size: 0.85em;
padding: 0;
} }
.debugger-container .breakpoints { .debugger-container .breakpoints {

View File

@@ -271,38 +271,6 @@
} }
} }
.pgadmin-controls {
padding-right: 0px;
padding-left: 0px;
}
.pgadmin-controls.SQL {
padding-right: 3px;
padding-left: 1px;
height: 100%;
}
.pgadmin-controls > textarea.form-control,
.pgadmin-controls > textarea.form-control:disabled {
min-width: 100%;
max-width: 100%;
}
.pgadmin-controls > div.checkbox, .pgadmin-controls > div.checkbox[disabled] {
height: 28px;
}
.pgadmin-controls > .uneditable-input, .pgadmin-controls > .pgadmin-node-select,
.pgadmin-controls > input.form-control, .pgadmin-controls > select.form-control,
.pgadmin-controls > .uneditable-input:disabled,
.pgadmin-controls > .pgadmin-node-select:disabled,
.pgadmin-controls > input.form-control:disabled,
.pgadmin-controls > select.form-control:disabled {
min-height: 28px;
}
.pgadmin-controls > span.select2 {
width: 100%;
}
fieldset.inline-fieldset { fieldset.inline-fieldset {
padding: 10px; padding: 10px;
border-radius: $card-border-radius; border-radius: $card-border-radius;
@@ -407,32 +375,6 @@ fieldset.inline-fieldset > div {
} }
} }
.pgadmin-controls input[type=checkbox]{
margin-left: 0 !important;
margin-top: 10px !important;
}
/* custom-control-label is used for checkbox */
.pgadmin-controls .custom-control-label{
margin-left: 0 !important;
margin-top: 5px !important;
}
.pgadmin-controls.sql_field_layout {
margin: 0;
padding: 0;
overflow: hidden;
z-index: 1;
}
.pgadmin-controls.focused,
.pgadmin-controls:focus {
border-color: $input-focus-border-color !important;
outline: 0;
-webkit-box-shadow: $input-focus-box-shadow;
box-shadow: $input-focus-box-shadow;
}
.dashboard-tab-container, .dashboard-tab-container,
.pg-panel-statistics-container, .pg-panel-statistics-container,
.pg-panel-dependencies-container, .pg-panel-dependencies-container,
@@ -496,13 +438,6 @@ fieldset.inline-fieldset > div {
.width_percent_99 { width: 99%; } .width_percent_99 { width: 99%; }
.width_percent_100 { width: 100%; } .width_percent_100 { width: 100%; }
.sql_field_layout {
border: $input-border-width solid $input-border-color !important;
border-radius: $input-border-radius;
padding: 0px;
}
.navtab-inline-controls { .navtab-inline-controls {
height: $title-height; height: $title-height;
@@ -894,25 +829,6 @@ table.table-empty-rows{
} }
} }
.pgadmin-controls-radio-none {
& input[type="radio"] {
display: none;
}
}
.backform-tab{
& > .nav.nav-tabs {
position: absolute;
top: 0;
left: 0;
right: 0;
}
& > .tab-content {
position: absolute;
top: $title-height;
bottom: $footer-height-calc;
}
}
.ajs-content { .ajs-content {
.tab-content { .tab-content {
bottom: 0; bottom: 0;

View File

@@ -621,12 +621,24 @@ def sql(trans_id, sgid, sid, did):
sql = '' sql = ''
tab_foreign_keys = [] tab_foreign_keys = []
all_nodes = data.get('nodes', {}) all_nodes = data.get('nodes', {})
table_sql = ''
for tab_key, tab_data in all_nodes.items(): for tab_key, tab_data in all_nodes.items():
tab_fks = tab_data.pop('foreign_key', []) tab_fks = tab_data.pop('foreign_key', [])
tab_foreign_keys.extend(translate_foreign_keys(tab_fks, tab_data, tab_foreign_keys.extend(translate_foreign_keys(tab_fks, tab_data,
all_nodes)) all_nodes))
sql += '\n\n' + helper.get_table_sql(tab_data, with_drop=with_drop) table_sql += '\n\n' + helper.get_table_sql(tab_data,
with_drop=with_drop)
if with_drop:
for tab_fk in tab_foreign_keys:
fk_sql = fkey_utils.get_delete_sql(conn, tab_fk)
sql += '\n\n' + fk_sql
if sql != '':
sql += '\n\n'
sql += table_sql
for tab_fk in tab_foreign_keys: for tab_fk in tab_foreign_keys:
fk_sql, name = fkey_utils.get_sql(conn, tab_fk, None) fk_sql, name = fkey_utils.get_sql(conn, tab_fk, None)
sql += '\n\n' + fk_sql sql += '\n\n' + fk_sql

View File

@@ -29,7 +29,3 @@
overflow: auto; overflow: auto;
border: 0 none; border: 0 none;
} }
.user_management .backform-tab {
height: calc(100% - 75px);
}