mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where the index is not loaded in the Unique Constraint dialog. Fixes #6857
This commit is contained in:
committed by
Akshay Joshi
parent
40b8da8223
commit
7eaa3179ad
@@ -6,6 +6,7 @@ import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../../../static/js/Sc
|
||||
import DataGridViewWithHeaderForm from '../../../../../../../../../../static/js/helpers/DataGridViewWithHeaderForm';
|
||||
import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../../../static/js/node_ajax';
|
||||
import { pgAlertify } from '../../../../../../../../../../static/js/helpers/legacyConnector';
|
||||
import TableSchema from '../../../../static/js/table.ui';
|
||||
|
||||
export function getNodeExclusionConstraintSchema(treeNodeInfo, itemNodeData, pgBrowser, noColumns=false) {
|
||||
let tableNode = pgBrowser.Nodes['table'];
|
||||
@@ -210,10 +211,10 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['exclusion_constraint']);
|
||||
return false;
|
||||
}
|
||||
|
||||
initialise(data) {
|
||||
|
||||
@@ -5,8 +5,9 @@ import { isEmptyString } from 'sources/validators';
|
||||
import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../../../static/js/SchemaView';
|
||||
import DataGridViewWithHeaderForm from '../../../../../../../../../../static/js/helpers/DataGridViewWithHeaderForm';
|
||||
import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../../../static/js/node_ajax';
|
||||
import TableSchema from '../../../../static/js/table.ui';
|
||||
|
||||
export function getNodeForeignKeySchema(treeNodeInfo, itemNodeData, pgBrowser, noColumns=false) {
|
||||
export function getNodeForeignKeySchema(treeNodeInfo, itemNodeData, pgBrowser, noColumns=false, initData={}) {
|
||||
return new ForeignKeySchema({
|
||||
local_column: noColumns ? [] : ()=>getNodeListByName('column', treeNodeInfo, itemNodeData),
|
||||
references: ()=>getNodeAjaxOptions('all_tables', pgBrowser.Nodes['table'], treeNodeInfo, itemNodeData, {cacheLevel: 'server'}, (rows)=>{
|
||||
@@ -27,7 +28,7 @@ export function getNodeForeignKeySchema(treeNodeInfo, itemNodeData, pgBrowser, n
|
||||
'label': r.name,
|
||||
}));
|
||||
});
|
||||
});
|
||||
}, initData);
|
||||
}
|
||||
|
||||
class ForeignKeyHeaderSchema extends BaseUISchema {
|
||||
@@ -110,7 +111,7 @@ class ForeignKeyColumnSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
export default class ForeignKeySchema extends BaseUISchema {
|
||||
constructor(fieldOptions={}, nodeInfo, getColumns) {
|
||||
constructor(fieldOptions={}, nodeInfo, getColumns, initData={}) {
|
||||
super({
|
||||
name: undefined,
|
||||
reftab: undefined,
|
||||
@@ -124,9 +125,10 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
columns: undefined,
|
||||
confupdtype: 'a',
|
||||
confdeltype: 'a',
|
||||
autoindex: ForeignKeySchema.checkInTable(nodeInfo) ? false : true,
|
||||
autoindex: true,
|
||||
coveringindex: undefined,
|
||||
hasindex:undefined,
|
||||
...initData,
|
||||
});
|
||||
|
||||
this.nodeInfo = nodeInfo;
|
||||
@@ -142,14 +144,10 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
return ForeignKeySchema.checkInTable(this.nodeInfo);
|
||||
}
|
||||
|
||||
static checkInTable(nodeInfo) {
|
||||
if(_.isUndefined(nodeInfo)) {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(nodeInfo['foreign_key']);
|
||||
return false;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import _ from 'lodash';
|
||||
import { isEmptyString } from 'sources/validators';
|
||||
import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../../../static/js/SchemaView';
|
||||
import TableSchema from '../../../../static/js/table.ui';
|
||||
export default class PrimaryKeySchema extends BaseUISchema {
|
||||
constructor(fieldOptions={}, nodeInfo) {
|
||||
super({
|
||||
@@ -28,10 +29,10 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['primary_key']);
|
||||
return false;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@@ -193,9 +194,9 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
id: 'index', label: gettext('Index'),
|
||||
mode: ['create'],
|
||||
type: 'select', group: gettext('Definition'),
|
||||
options: this.fieldOptions.index,
|
||||
controlProps:{
|
||||
allowClear:true,
|
||||
options: this.fieldOptions.index,
|
||||
},
|
||||
readonly: function() {
|
||||
if(!obj.isNew()) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import _ from 'lodash';
|
||||
import { isEmptyString } from 'sources/validators';
|
||||
import { SCHEMA_STATE_ACTIONS } from '../../../../../../../../../../static/js/SchemaView';
|
||||
import TableSchema from '../../../../static/js/table.ui';
|
||||
|
||||
export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
constructor(fieldOptions={}, nodeInfo) {
|
||||
@@ -29,10 +30,10 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['unique_constraint']);
|
||||
return false;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@@ -196,9 +197,9 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
id: 'index', label: gettext('Index'),
|
||||
mode: ['create'],
|
||||
type: 'select', group: gettext('Definition'),
|
||||
options: this.fieldOptions.index,
|
||||
controlProps:{
|
||||
allowClear:true,
|
||||
options: this.fieldOptions.index,
|
||||
},
|
||||
readonly: function() {
|
||||
if(!obj.isNew()) {
|
||||
|
||||
@@ -48,7 +48,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) {
|
||||
vacuum_settings: ()=>getNodeVacuumSettingsSchema(tableNode, treeNodeInfo, itemNodeData),
|
||||
constraints: ()=>new ConstraintsSchema(
|
||||
treeNodeInfo,
|
||||
()=>getNodeForeignKeySchema(treeNodeInfo, itemNodeData, pgBrowser, true),
|
||||
()=>getNodeForeignKeySchema(treeNodeInfo, itemNodeData, pgBrowser, true, {autoindex: false}),
|
||||
()=>getNodeExclusionConstraintSchema(treeNodeInfo, itemNodeData, pgBrowser, true),
|
||||
{spcname: spcname},
|
||||
),
|
||||
@@ -275,8 +275,8 @@ export class LikeSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
export default class TableSchema extends BaseUISchema {
|
||||
constructor(fieldOptions={}, nodeInfo, schemas, getPrivilegeRoleSchema, getColumns,
|
||||
getCollations, getOperatorClass, getAttachTables, initValues) {
|
||||
constructor(fieldOptions={}, nodeInfo, schemas={}, getPrivilegeRoleSchema=()=>{}, getColumns=()=>[],
|
||||
getCollations=()=>[], getOperatorClass=()=>[], getAttachTables=()=>[], initValues={}) {
|
||||
super({
|
||||
name: undefined,
|
||||
oid: undefined,
|
||||
@@ -321,9 +321,9 @@ export default class TableSchema extends BaseUISchema {
|
||||
this.getColumns = getColumns;
|
||||
|
||||
this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, getAttachTables);
|
||||
this.constraintsObj = this.schemas.constraints();
|
||||
this.columnsSchema = this.schemas.columns();
|
||||
this.vacuumSettingsSchema = this.schemas.vacuum_settings();
|
||||
this.constraintsObj = this.schemas.constraints && this.schemas.constraints() || {};
|
||||
this.columnsSchema = this.schemas.columns && this.schemas.columns() || {};
|
||||
this.vacuumSettingsSchema = this.schemas.vacuum_settings && this.schemas.vacuum_settings() || {};
|
||||
this.partitionKeysObj = new PartitionKeysSchema([], getCollations, getOperatorClass);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user