Ensure that the referenced table should be displayed on foreign key constraints. Fixes #5530
parent
8b10315e2a
commit
1802f8a3f8
|
@ -22,6 +22,7 @@ Bug fixes
|
||||||
|
|
||||||
| `Issue #3851 <https://redmine.postgresql.org/issues/3851>`_ - Add proper indentation to the code while generating functions, procedures, and trigger functions.
|
| `Issue #3851 <https://redmine.postgresql.org/issues/3851>`_ - Add proper indentation to the code while generating functions, procedures, and trigger functions.
|
||||||
| `Issue #4235 <https://redmine.postgresql.org/issues/4235>`_ - Fixed tab indent issue on a selection of lines is deleting the content when 'use spaces == true' in the preferences.
|
| `Issue #4235 <https://redmine.postgresql.org/issues/4235>`_ - Fixed tab indent issue on a selection of lines is deleting the content when 'use spaces == true' in the preferences.
|
||||||
|
| `Issue #5530 <https://redmine.postgresql.org/issues/5530>`_ - Ensure that the referenced table should be displayed on foreign key constraints.
|
||||||
| `Issue #5621 <https://redmine.postgresql.org/issues/5621>`_ - Remove extra brackets from reverse engineering SQL of RLS Policy.
|
| `Issue #5621 <https://redmine.postgresql.org/issues/5621>`_ - Remove extra brackets from reverse engineering SQL of RLS Policy.
|
||||||
| `Issue #5630 <https://redmine.postgresql.org/issues/5630>`_ - Fixed an issue where installation of pgadmin4 not working on 32-bit Windows.
|
| `Issue #5630 <https://redmine.postgresql.org/issues/5630>`_ - Fixed an issue where installation of pgadmin4 not working on 32-bit Windows.
|
||||||
| `Issue #5631 <https://redmine.postgresql.org/issues/5631>`_ - Fixed 'cant execute empty query' issue when remove the value of 'USING' or 'WITH CHECK' option of RLS Policy.
|
| `Issue #5631 <https://redmine.postgresql.org/issues/5631>`_ - Fixed 'cant execute empty query' issue when remove the value of 'USING' or 'WITH CHECK' option of RLS Policy.
|
|
@ -51,11 +51,15 @@ define('pgadmin.node.foreign_key', [
|
||||||
},
|
},
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'local_column', label: gettext('Local'), type:'text', editable: false,
|
id: 'local_column', label: gettext('Local'), type:'text', editable: false,
|
||||||
cellHeaderClasses: 'width_percent_50', cell:'string',
|
cellHeaderClasses: 'width_percent_35', cell:'string',
|
||||||
headerCell: Backgrid.Extension.CustomHeaderCell,
|
headerCell: Backgrid.Extension.CustomHeaderCell,
|
||||||
},{
|
},{
|
||||||
id: 'referenced', label: gettext('Referenced'), type: 'text', editable: false,
|
id: 'referenced', label: gettext('Referenced'), type: 'text', editable: false,
|
||||||
cell:'string', cellHeaderClasses: 'width_percent_50',
|
cell:'string', cellHeaderClasses: 'width_percent_35',
|
||||||
|
headerCell: Backgrid.Extension.CustomHeaderCell,
|
||||||
|
},{
|
||||||
|
id: 'references_table_name', label: gettext('Referenced Table'), type: 'text', editable: false,
|
||||||
|
cell:'string', cellHeaderClasses: 'width_percent_30',
|
||||||
headerCell: Backgrid.Extension.CustomHeaderCell,
|
headerCell: Backgrid.Extension.CustomHeaderCell,
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
@ -203,6 +207,9 @@ define('pgadmin.node.foreign_key', [
|
||||||
url = self.field.get('url') || self.defaults.url,
|
url = self.field.get('url') || self.defaults.url,
|
||||||
m = self.model,
|
m = self.model,
|
||||||
tid = m.get('references');
|
tid = m.get('references');
|
||||||
|
// Store name for selected table
|
||||||
|
var a = $('select[name="references"]').find(':selected').text();
|
||||||
|
this.model.set('references_table_name', a,{silent: true});
|
||||||
|
|
||||||
// Clear any existing value before setting new options.
|
// Clear any existing value before setting new options.
|
||||||
m.set(self.field.get('name'), null, {silent: true});
|
m.set(self.field.get('name'), null, {silent: true});
|
||||||
|
@ -267,7 +274,7 @@ define('pgadmin.node.foreign_key', [
|
||||||
headerDefaults = {local_column: null,
|
headerDefaults = {local_column: null,
|
||||||
references: null,
|
references: null,
|
||||||
referenced:null},
|
referenced:null},
|
||||||
gridCols = ['local_column', 'references', 'referenced'];
|
gridCols = ['local_column', 'references', 'referenced','references_table_name'];
|
||||||
|
|
||||||
if ((!self.model.isNew() && _.isUndefined(self.model.handler)) ||
|
if ((!self.model.isNew() && _.isUndefined(self.model.handler)) ||
|
||||||
(_.has(self.model, 'handler') &&
|
(_.has(self.model, 'handler') &&
|
||||||
|
@ -689,6 +696,7 @@ define('pgadmin.node.foreign_key', [
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
reftab: undefined,
|
||||||
oid: undefined,
|
oid: undefined,
|
||||||
is_sys_obj: undefined,
|
is_sys_obj: undefined,
|
||||||
comment: undefined,
|
comment: undefined,
|
||||||
|
@ -712,7 +720,7 @@ define('pgadmin.node.foreign_key', [
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'name', label: gettext('Name'), type: 'text',
|
id: 'name', label: gettext('Name'), type: 'text',
|
||||||
mode: ['properties', 'create', 'edit'], editable:true,
|
mode: ['properties', 'create', 'edit'], editable:true,
|
||||||
headerCell: Backgrid.Extension.CustomHeaderCell, cellHeaderClasses: 'width_percent_50',
|
headerCell: Backgrid.Extension.CustomHeaderCell, cellHeaderClasses: 'width_percent_30',
|
||||||
},{
|
},{
|
||||||
id: 'oid', label: gettext('OID'), cell: 'string',
|
id: 'oid', label: gettext('OID'), cell: 'string',
|
||||||
type: 'text' , mode: ['properties'],
|
type: 'text' , mode: ['properties'],
|
||||||
|
@ -898,11 +906,45 @@ define('pgadmin.node.foreign_key', [
|
||||||
// We can't update columns of existing foreign key.
|
// We can't update columns of existing foreign key.
|
||||||
return !m.isNew();
|
return !m.isNew();
|
||||||
},
|
},
|
||||||
|
},{
|
||||||
|
id: 'references_table_name', label: gettext('Referenced Table'),
|
||||||
|
type: 'text', group: gettext('Columns'),
|
||||||
|
node: 'foreign_key', editable: false,visible:false,
|
||||||
|
cellHeaderClasses: 'width_percent_30',
|
||||||
|
cell: Backgrid.StringCell.extend({
|
||||||
|
initialize: function() {
|
||||||
|
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
||||||
|
var self = this,
|
||||||
|
collection = this.model.get('columns');
|
||||||
|
self.model.get('columns').on('pgadmin:columns:updated', function() {
|
||||||
|
self.render.apply(self);
|
||||||
|
});
|
||||||
|
self.listenTo(collection, 'add', self.render);
|
||||||
|
self.listenTo(collection, 'remove', self.render);
|
||||||
|
},
|
||||||
|
formatter: {
|
||||||
|
fromRaw: function (rawValue,model,) {
|
||||||
|
var remote_tables = [],
|
||||||
|
m = model.get('columns');
|
||||||
|
if (m.length > 0) {
|
||||||
|
m.each(function(col){
|
||||||
|
remote_tables.push(col.get('references_table_name'));
|
||||||
|
});
|
||||||
|
return remote_tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
toRaw: function (val) { return val; },
|
||||||
|
},
|
||||||
|
render: function() {
|
||||||
|
return Backgrid.StringCell.prototype.render.apply(this, arguments);
|
||||||
|
},
|
||||||
|
}),
|
||||||
},{
|
},{
|
||||||
id: 'columns', label: gettext('Columns'),
|
id: 'columns', label: gettext('Columns'),
|
||||||
type: 'collection', group: gettext('Columns'),
|
type: 'collection', group: gettext('Columns'),
|
||||||
node: 'foreign_key', editable: false, headerCell: Backgrid.Extension.CustomHeaderCell,
|
node: 'foreign_key', editable: false, headerCell: Backgrid.Extension.CustomHeaderCell,
|
||||||
cellHeaderClasses: 'width_percent_50',
|
cellHeaderClasses: 'width_percent_30',
|
||||||
cell: Backgrid.StringCell.extend({
|
cell: Backgrid.StringCell.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
||||||
|
|
|
@ -69,7 +69,9 @@ def get_foreign_keys(conn, tid, fkid=None, template_path=None):
|
||||||
for row in res['rows']:
|
for row in res['rows']:
|
||||||
columns.append({"local_column": row['conattname'],
|
columns.append({"local_column": row['conattname'],
|
||||||
"references": fk['confrelid'],
|
"references": fk['confrelid'],
|
||||||
"referenced": row['confattname']})
|
"referenced": row['confattname'],
|
||||||
|
"references_table_name":
|
||||||
|
fk['refnsp'] + '.' + fk['reftab']})
|
||||||
cols.append(row['conattname'])
|
cols.append(row['conattname'])
|
||||||
|
|
||||||
fk['columns'] = columns
|
fk['columns'] = columns
|
||||||
|
|
|
@ -698,7 +698,7 @@ define('pgadmin.node.table', [
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
columns : ['name', 'columns'],
|
columns : ['name', 'columns','references_table_name'],
|
||||||
canAddRow: function(m) {
|
canAddRow: function(m) {
|
||||||
// User can only add if there is at least one column with name.
|
// User can only add if there is at least one column with name.
|
||||||
var columns = m.get('columns');
|
var columns = m.get('columns');
|
||||||
|
|
Loading…
Reference in New Issue