public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded
@ 2021-10-04 12:56 Aditya Toshniwal <[email protected]>
2021-10-04 14:10 ` Re: [pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded Akshay Joshi <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Toshniwal @ 2021-10-04 12:56 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Please review the attached patch for the fix.
--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM6857.patch (15.1K, 3-RM6857.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js
index e405c0ac9..3362cd785 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js
@@ -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) {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
index 979b70706..5903f5394 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
@@ -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) {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js
index 52e2ca5a4..e1079f6e5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js
@@ -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()) {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js
index 0bdc30719..b9e899e8b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js
@@ -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()) {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js
index 3344be5d8..94622e2b3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js
@@ -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);
}
diff --git a/web/regression/javascript/schema_ui_files/exclusion_constraint.ui.spec.js b/web/regression/javascript/schema_ui_files/exclusion_constraint.ui.spec.js
index a4e52c448..14a651054 100644
--- a/web/regression/javascript/schema_ui_files/exclusion_constraint.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/exclusion_constraint.ui.spec.js
@@ -19,6 +19,7 @@ import _ from 'lodash';
import { getNodeExclusionConstraintSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui';
import * as legacyConnector from 'sources/helpers/legacyConnector';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
+import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -196,6 +197,7 @@ describe('ExclusionConstraintSchema', ()=>{
it('depChange', ()=>{
let state = {columns: [{local_column: 'id'}]};
+ schemaObj.top = new TableSchema({}, null);
expect(getFieldDepChange(schemaObj, 'columns')(state, ['columns', 0], null, {
type: SCHEMA_STATE_ACTIONS.DELETE_ROW,
oldState: {
diff --git a/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js b/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js
index 0bd8c0f94..7b7288eaa 100644
--- a/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js
@@ -18,6 +18,7 @@ import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import { getNodeForeignKeySchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui';
+import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -197,8 +198,7 @@ describe('ForeignKeySchema', ()=>{
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({});
state.oid = null;
- schemaObj.nodeInfo = {table: {}};
- schemaObj.top = schemaObj;
+ schemaObj.top = new TableSchema({}, null);
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
autoindex: false,
coveringindex: '',
diff --git a/web/regression/javascript/schema_ui_files/primary_key.ui.spec.js b/web/regression/javascript/schema_ui_files/primary_key.ui.spec.js
index bc4fbe453..2a48f69b4 100644
--- a/web/regression/javascript/schema_ui_files/primary_key.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/primary_key.ui.spec.js
@@ -17,6 +17,7 @@ import SchemaView, { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/Sch
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import PrimaryKeySchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui';
+import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -172,6 +173,7 @@ describe('PrimaryKeySchema', ()=>{
expect(getFieldDepChange(schemaObj, 'condeferrable')(state)).toEqual({});
expect(getFieldDepChange(schemaObj, 'condeferred')(state)).toEqual({});
+ schemaObj.top = new TableSchema({}, null);
expect(getFieldDepChange(schemaObj, 'columns')(state, ['columns', 0], null, {
type: SCHEMA_STATE_ACTIONS.DELETE_ROW,
oldState: {
diff --git a/web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js b/web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js
index c345c475c..b1c0423e4 100644
--- a/web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js
@@ -17,6 +17,7 @@ import SchemaView, { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/Sch
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import UniqueConstraintSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui';
+import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -171,6 +172,7 @@ describe('UniqueConstraintSchema', ()=>{
expect(getFieldDepChange(schemaObj, 'condeferrable')(state)).toEqual({});
expect(getFieldDepChange(schemaObj, 'condeferred')(state)).toEqual({});
+ schemaObj.top = new TableSchema({}, null);
expect(getFieldDepChange(schemaObj, 'columns')(state, ['columns', 0], null, {
type: SCHEMA_STATE_ACTIONS.DELETE_ROW,
oldState: {
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded
2021-10-04 12:56 [pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded Aditya Toshniwal <[email protected]>
@ 2021-10-04 14:10 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Akshay Joshi @ 2021-10-04 14:10 UTC (permalink / raw)
To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers
Thanks, the patch applied.
On Mon, Oct 4, 2021 at 6:26 PM Aditya Toshniwal <
[email protected]> wrote:
> Hi Hackers,
>
> Please review the attached patch for the fix.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin Hacker | Software Architect | *edbpostgres.com*
> <http://edbpostgres.com;
> "Don't Complain about Heat, Plant a TREE"
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-10-04 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 12:56 [pgAdmin][RM6857] Unique Constraint dialogue > Index dropdown does not have options loaded Aditya Toshniwal <[email protected]>
2021-10-04 14:10 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox