Re: [pgAdmin4][Patch] - RM 4742 - Can not create Primary key with Index & 4624 - RE-SQL/MSQL test cases for Primary Keys
Khushboo Vashi <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.pgadmin.devel |
|---|---|
| Message-ID | <CAFOhELeDpMz0=Mp+WRbUTbHCA8BGjoZcNGe+AcdZyRwH7JMLXg@mail.gmail.com> |
Hi Akshay, Please find the attached updated patch. On Fri, Sep 13, 2019 at 6:10 PM Akshay Joshi <[email protected]> wrote: > Hi Khushboo > > Following are my review comments: > > - Test cases failed on every server. > > Fixed. > > - Delete table scenario is missing in check_constraints and > index_constraints. > > It is not necessary though I have added. > > - Scenario "Primary Key Constraint with Index" is missing in the > 11_plus folder, it is available in the default folder. > > Added. > > - Found one issue when we remove fill factor no MSQL is generated and > got the error "can't execute an empty query". > > Fixed the existing issue for the Primary key. > > - Index is not visible in the properties dialog when we create primary > key using index. > > Whenever the Primary key is created using Index, the index name is changed to PK's name. So, I have hide the Index field from the Properties and Edit dialogue. Thanks, Khushboo > > - > > > On Fri, Sep 13, 2019 at 2:41 PM Khushboo Vashi < > [email protected]> wrote: > >> Hi, >> >> Please find the attached patch to fix below RMs. >> >> 1. #4742 - Primary Key Dialog: Can not create Primary key with Index >> 2. #4624 - Add RE-SQL/MSQL test cases for Primary Keys >> >> Thanks, >> Khushboo >> > > > -- > *Thanks & Regards* > *Akshay Joshi* > > *Sr. Software Architect* > *EnterpriseDB Software India Private Limited* > *Mobile: +91 976-788-8246* >
RM_4624_4742_v1.patch
(application/octet-stream, 28.4 KB)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json
index 9f99ba790..6e229fd91 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json
@@ -51,6 +51,13 @@
"data": {
"name": "Chk_$%{}[]()&*^!@\"'`\\/#a"
}
+ }, {
+ "type": "delete",
+ "name": "Drop Table for Check Constraint",
+ "endpoint": "NODE-table.delete_id",
+ "data": {
+ "name": "tableforcon"
+ }
}
]
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
index fb733ad67..c45f243c0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -571,7 +571,8 @@ class IndexConstraintView(PGChildNodeView):
for arg in required_args:
if isinstance(arg, list):
for param in arg:
- if param in data and is_key_list(param, data):
+ if param in data and (param != 'columns' or
+ is_key_list(param, data)):
break
else:
return make_json_response(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
index 7d363c204..292118650 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
@@ -533,14 +533,11 @@ define('pgadmin.node.primary_key', [
},
},{
id: 'index', label: gettext('Index'),
+ mode: ['create'],
type: 'text', group: gettext('Definition'),
control: Backform.NodeListByNameControl.extend({
initialize:function() {
- if (_.isUndefined(this.model.top)) {
- Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
- } else {
- Backform.Control.prototype.initialize.apply(this,arguments);
- }
+ Backform.NodeListByNameControl.prototype.initialize.apply(this, arguments);
},
}),
select2:{allowClear:true}, node: 'index',
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint.sql
new file mode 100644
index 000000000..dc3cf3dab
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint.sql
@@ -0,0 +1,13 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" PRIMARY KEY (col1)
+ INCLUDE (col2)
+ WITH (FILLFACTOR=90)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint_with_index.sql
new file mode 100644
index 000000000..d5c2dc067
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_index_constraint_with_index.sql
@@ -0,0 +1,11 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=90);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint.sql
new file mode 100644
index 000000000..7031f24f9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ RENAME CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" TO "Pk_$%{}[]()&*^!@""'`\/#a";
+ALTER INDEX testschema."Pk_$%{}[]()&*^!@""'`\/#a"
+ SET (FILLFACTOR=90);
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint_with_index.sql
new file mode 100644
index 000000000..7031f24f9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/alter_msql_index_constraint_with_index.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ RENAME CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" TO "Pk_$%{}[]()&*^!@""'`\/#a";
+ALTER INDEX testschema."Pk_$%{}[]()&*^!@""'`\/#a"
+ SET (FILLFACTOR=90);
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint.sql
new file mode 100644
index 000000000..2fcf106ae
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint.sql
@@ -0,0 +1,12 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ INCLUDE (col2)
+ WITH (FILLFACTOR=20)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint_with_index.sql
new file mode 100644
index 000000000..70aa78d4b
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_index_constraint_with_index.sql
@@ -0,0 +1,10 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint.sql
new file mode 100644
index 000000000..433a42643
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint.sql
@@ -0,0 +1,8 @@
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ INCLUDE (col2)
+ WITH (FILLFACTOR=20)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint_with_index.sql
new file mode 100644
index 000000000..e1e943668
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/create_msql_index_constraint_with_index.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/test.json
new file mode 100644
index 000000000..f23520286
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/11_plus/test.json
@@ -0,0 +1,118 @@
+{
+ "scenarios": [
+ {
+ "type": "create",
+ "name": "Create Table",
+ "endpoint": "NODE-table.obj",
+ "sql_endpoint": "NODE-table.sql_id",
+ "data": {
+ "name": "tableforindexcon",
+ "columns": [{
+ "name": "col1",
+ "cltype": "integer",
+ "is_primary_key": false
+ }, {
+ "name": "col2",
+ "cltype": "integer",
+ "is_primary_key": false
+ }],
+ "is_partitioned": false,
+ "schema": "testschema",
+ "spcname": "pg_default"
+ },
+ "store_object_id": true
+ }, {
+ "type": "create",
+ "name": "Create Index",
+ "endpoint": "NODE-index.obj",
+ "sql_endpoint": "NODE-index.sql_id",
+ "data": {
+ "name": "uindex",
+ "spcname": "pg_default",
+ "amname": "btree",
+ "columns": [{
+ "colname": "col1",
+ "sort_order": false,
+ "nulls": false,
+ "is_sort_nulls_applicable": true
+ }],
+ "indisunique": true,
+ "fillfactor": 20
+ }
+ }, {
+ "type": "create",
+ "name": "Create Primary Key Constraint -- 11 Plus",
+ "endpoint": "NODE-primary_key.obj",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#",
+ "comment": "Comment for create",
+ "fillfactor": 20,
+ "columns": [{"column":"col1"}],
+ "include": ["col2"],
+ "condeferrable": true,
+ "condeferred": true
+ },
+ "expected_sql_file": "create_index_constraint.sql",
+ "expected_msql_file": "create_msql_index_constraint.sql"
+ }, {
+ "type": "alter",
+ "name": "Alter Primary Key Constraint -- 11 Plus",
+ "endpoint": "NODE-primary_key.obj_id",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "msql_endpoint": "NODE-primary_key.msql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a",
+ "fillfactor": 90,
+ "comment": "Comment for alter"
+ },
+ "expected_sql_file": "alter_index_constraint.sql",
+ "expected_msql_file": "alter_msql_index_constraint.sql"
+ }, {
+ "type": "delete",
+ "name": "Drop Primary Key Constraint -- 11 plus",
+ "endpoint": "NODE-primary_key.delete_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a"
+ }
+ }, {
+ "type": "create",
+ "name": "Create Primary Key Constraint with Index -- 11 plus",
+ "endpoint": "NODE-primary_key.obj",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#",
+ "comment": "Comment for create",
+ "index": "uindex"
+ },
+ "expected_sql_file": "create_index_constraint_with_index.sql"
+ }, {
+ "type": "alter",
+ "name": "Alter Primary Key Constraint with Index -- 11 plus",
+ "endpoint": "NODE-primary_key.obj_id",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "msql_endpoint": "NODE-primary_key.msql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a",
+ "fillfactor": 90,
+ "comment": "Comment for alter"
+ },
+ "expected_sql_file": "alter_index_constraint_with_index.sql",
+ "expected_msql_file": "alter_msql_index_constraint_with_index.sql"
+ }, {
+ "type": "delete",
+ "name": "Drop Primary Key Constraint with Index -- 11 plus",
+ "endpoint": "NODE-primary_key.delete_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a"
+ }
+ }, {
+ "type": "delete",
+ "name": "Drop Index Constraint Table -- 11 plus",
+ "endpoint": "NODE-table.delete_id",
+ "data": {
+ "name": "tableforindexcon"
+ }
+ }
+ ]
+}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint.sql
new file mode 100644
index 000000000..0af807b99
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint.sql
@@ -0,0 +1,12 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=90)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint_with_index.sql
new file mode 100644
index 000000000..d5c2dc067
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_index_constraint_with_index.sql
@@ -0,0 +1,11 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=90);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint.sql
new file mode 100644
index 000000000..7031f24f9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ RENAME CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" TO "Pk_$%{}[]()&*^!@""'`\/#a";
+ALTER INDEX testschema."Pk_$%{}[]()&*^!@""'`\/#a"
+ SET (FILLFACTOR=90);
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint_with_index.sql
new file mode 100644
index 000000000..7031f24f9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/alter_msql_index_constraint_with_index.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ RENAME CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" TO "Pk_$%{}[]()&*^!@""'`\/#a";
+ALTER INDEX testschema."Pk_$%{}[]()&*^!@""'`\/#a"
+ SET (FILLFACTOR=90);
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforindexcon
+ IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint.sql
new file mode 100644
index 000000000..42a9f8004
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint.sql
@@ -0,0 +1,11 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint_with_index.sql
new file mode 100644
index 000000000..70aa78d4b
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_index_constraint_with_index.sql
@@ -0,0 +1,10 @@
+-- Constraint: Pk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforindexcon DROP CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint.sql
new file mode 100644
index 000000000..aac679e6e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint.sql
@@ -0,0 +1,7 @@
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20)
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint_with_index.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint_with_index.sql
new file mode 100644
index 000000000..e1e943668
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/create_msql_index_constraint_with_index.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforindexcon
+ ADD CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" PRIMARY KEY (col1)
+ WITH (FILLFACTOR=20);
+
+COMMENT ON CONSTRAINT "Pk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforindexcon
+ IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/test.json
new file mode 100644
index 000000000..ec8d010c6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/tests/default/test.json
@@ -0,0 +1,113 @@
+{
+ "scenarios": [
+ {
+ "type": "create",
+ "name": "Create Table",
+ "endpoint": "NODE-table.obj",
+ "sql_endpoint": "NODE-table.sql_id",
+ "data": {
+ "name": "tableforindexcon",
+ "columns": [{
+ "name": "col1",
+ "cltype": "integer",
+ "is_primary_key": false
+ }],
+ "is_partitioned": false,
+ "schema": "testschema",
+ "spcname": "pg_default"
+ },
+ "store_object_id": true
+ }, {
+ "type": "create",
+ "name": "Create Index",
+ "endpoint": "NODE-index.obj",
+ "sql_endpoint": "NODE-index.sql_id",
+ "data": {
+ "name": "uindex",
+ "spcname": "pg_default",
+ "amname": "btree",
+ "columns": [{
+ "colname": "col1",
+ "sort_order": false,
+ "nulls": false,
+ "is_sort_nulls_applicable": true
+ }],
+ "indisunique": true,
+ "fillfactor": 20
+ }
+ }, {
+ "type": "create",
+ "name": "Create Primary Key Constraint",
+ "endpoint": "NODE-primary_key.obj",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#",
+ "comment": "Comment for create",
+ "fillfactor": 20,
+ "columns": [{"column":"col1"}],
+ "condeferrable": true,
+ "condeferred": true
+ },
+ "expected_sql_file": "create_index_constraint.sql",
+ "expected_msql_file": "create_msql_index_constraint.sql"
+ }, {
+ "type": "alter",
+ "name": "Alter Primary Key Constraint",
+ "endpoint": "NODE-primary_key.obj_id",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "msql_endpoint": "NODE-primary_key.msql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a",
+ "fillfactor": 90,
+ "comment": "Comment for alter"
+ },
+ "expected_sql_file": "alter_index_constraint.sql",
+ "expected_msql_file": "alter_msql_index_constraint.sql"
+ }, {
+ "type": "delete",
+ "name": "Drop Primary Key Constraint",
+ "endpoint": "NODE-primary_key.delete_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a"
+ }
+ }, {
+ "type": "create",
+ "name": "Create Primary Key Constraint with Index",
+ "endpoint": "NODE-primary_key.obj",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#",
+ "comment": "Comment for create",
+ "index": "uindex"
+ },
+ "expected_sql_file": "create_index_constraint_with_index.sql"
+ }, {
+ "type": "alter",
+ "name": "Alter Primary Key Constraint with Index",
+ "endpoint": "NODE-primary_key.obj_id",
+ "sql_endpoint": "NODE-primary_key.sql_id",
+ "msql_endpoint": "NODE-primary_key.msql_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a",
+ "fillfactor": 90,
+ "comment": "Comment for alter"
+ },
+ "expected_sql_file": "alter_index_constraint_with_index.sql",
+ "expected_msql_file": "alter_msql_index_constraint_with_index.sql"
+ }, {
+ "type": "delete",
+ "name": "Drop Primary Key Constraint with Index",
+ "endpoint": "NODE-primary_key.delete_id",
+ "data": {
+ "name": "Pk_$%{}[]()&*^!@\"'`\\/#a"
+ }
+ }, {
+ "type": "delete",
+ "name": "Drop Index Constraint Table",
+ "endpoint": "NODE-table.delete_id",
+ "data": {
+ "name": "tableforindexcon"
+ }
+ }
+ ]
+}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/11_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/11_plus/create.sql
index 5d85ec7b1..8956cdc99 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/11_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/11_plus/create.sql
@@ -1,9 +1,9 @@
ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} {{constraint_name}} {% if data.index %}USING INDEX {{ conn|qtIdent(data.index) }}{% else %}
({% for columnobj in data.columns %}{% if loop.index != 1 %}
-, {% endif %}{{ conn|qtIdent(columnobj.column)}}{% endfor %})
-{% if data.include|length > 0 %}
- INCLUDE({% for col in data.include %}{% if loop.index != 1 %}, {% endif %}{{conn|qtIdent(col)}}{% endfor %}){% endif %}
+, {% endif %}{{ conn|qtIdent(columnobj.column)}}{% endfor %}){% if data.include|length > 0 %}
+
+ INCLUDE ({% for col in data.include %}{% if loop.index != 1 %}, {% endif %}{{conn|qtIdent(col)}}{% endfor %}){% endif %}
{% if data.fillfactor %}
WITH (FILLFACTOR={{data.fillfactor}}){% endif %}{% if data.spcname and data.spcname != "pg_default" %}
@@ -12,7 +12,7 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
DEFERRABLE{% if data.condeferred %}
INITIALLY DEFERRED{% endif%}
-{% endif%};
+{% endif -%};
{% if data.comment and data.name %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/create.sql
index 2bd34a473..c83dd99fe 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/create.sql
@@ -9,9 +9,9 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
DEFERRABLE{% if data.condeferred %}
INITIALLY DEFERRED{% endif%}
-{% endif%};
+{% endif -%};
{% if data.comment and data.name %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
index abc064e7f..8d4301a99 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
@@ -13,6 +13,9 @@ ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
{% if data.fillfactor and data.fillfactor != o_data.fillfactor %}
ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
SET (FILLFACTOR={{ data.fillfactor }});
+{% elif data.fillfactor is defined and data.fillfactor == '' %}
+ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
+ RESET (FILLFACTOR);
{% endif %}
{# ==== To update constraint comments ==== #}
{% if data.comment is defined and data.comment != o_data.comment %}