public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
4+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
@ 2019-07-16 06:22 Khushboo Vashi <[email protected]>
  2019-07-16 08:35 ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Khushboo Vashi @ 2019-07-16 06:22 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

Please find the attached patch for the RE-SQL and modified SQL tests for
check constraint node.

For the table child nodes, *create table endpoint *with proper data is
required in the JSON file.
I have introduced one new parameter named *store_table_id* in the table
create endpoint, so the created table ID will be stored for the rest of the
scenarios.

Thanks,
Khushboo


Attachments:

  [application/octet-stream] resql_check_constraint.patch (6.1K, 3-resql_check_constraint.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql
new file mode 100644
index 00000000..e9985430
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql
@@ -0,0 +1,9 @@
+-- Constraint: Chk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforcon DROP CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforcon
+    ADD CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" CHECK (col1 > 1);
+
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforcon
+    IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql
new file mode 100644
index 00000000..9afc729b
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql
@@ -0,0 +1,10 @@
+-- Constraint: Chk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforcon DROP CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforcon
+    ADD CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" CHECK (col1 > 1)
+    NOT VALID;
+
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforcon
+    IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql
new file mode 100644
index 00000000..6f1fd8d3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforcon
+    RENAME CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" TO "Chk_$%{}[]()&*^!@""'`\/#a";
+ALTER TABLE testschema.tableforcon
+    VALIDATE CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a";
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforcon
+    IS 'Comment for alter';
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
new file mode 100644
index 00000000..a5fb3671
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json
@@ -0,0 +1,56 @@
+{
+  "scenarios": [
+    {
+      "type": "create",
+      "name": "Create Table",
+      "endpoint": "NODE-table.obj",
+      "sql_endpoint": "NODE-table.sql_id",
+      "data": {
+        "name": "tableforcon",
+        "columns": [{
+          "name": "col1",
+          "cltype": "integer",
+          "is_primary_key": true
+        }],
+        "is_partitioned": false,
+        "schema": "testschema",
+        "spcname": "pg_default"
+      },
+      "store_table_id": true
+    },
+    {
+      "type": "create",
+      "name": "Create Check Constraint",
+      "endpoint": "NODE-check_constraint.obj",
+      "sql_endpoint": "NODE-check_constraint.sql_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#",
+        "comment": "Comment for create",
+        "consrc": "col1 > 1",
+        "connoinherit": false,
+        "convalidated": true
+      },
+      "expected_sql_file": "create_check_constraint.sql"
+    }, {
+      "type": "alter",
+      "name": "Alter Check Constraint",
+      "endpoint": "NODE-check_constraint.obj_id",
+      "sql_endpoint": "NODE-check_constraint.sql_id",
+      "msql_endpoint": "NODE-check_constraint.msql_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#a",
+        "convalidated": false,
+        "comment": "Comment for alter"
+      },
+      "expected_sql_file": "alter_check_constraint.sql",
+      "expected_msql_file": "msql_check_constraint.sql"
+    }, {
+      "type": "delete",
+      "name": "Drop Check Constraint",
+      "endpoint": "NODE-check_constraint.delete_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#a"
+      }
+    }
+  ]
+}
diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py
index 6b87f030..6bb54d9e 100644
--- a/web/regression/re_sql/tests/test_resql.py
+++ b/web/regression/re_sql/tests/test_resql.py
@@ -151,6 +151,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                     options['did'] = int(self.server_information['db_id'])
                 elif arg == 'scid':
                     options['scid'] = int(self.schema_id)
+                elif arg == 'tid':
+                    options['tid'] = int(self.table_id)
                 else:
                     if object_id is not None:
                         options[arg] = int(object_id)
@@ -212,6 +214,10 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                 resp_data = json.loads(response.data.decode('utf8'))
                 object_id = resp_data['node']['_id']
 
+                # Table child nodes require table id
+                if 'store_table_id' in scenario:
+                    self.table_id = object_id
+
                 # Compare the reverse engineering SQL
                 if not self.check_re_sql(scenario, object_id):
                     print_msg = scenario['name']
@@ -320,6 +326,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                                 object_id)
 
         params = urllib.parse.urlencode(scenario['data'])
+        params = params.replace('False', 'false').replace('True', 'true')
         url = msql_url + "?%s" % params
         response = self.tester.get(url,
                                    follow_redirects=True)


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
  2019-07-16 06:22 [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
@ 2019-07-16 08:35 ` Dave Page <[email protected]>
  2019-07-16 11:01   ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Page @ 2019-07-16 08:35 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Hi

On Tue, Jul 16, 2019 at 7:22 AM Khushboo Vashi <
[email protected]> wrote:

> Hi,
>
> Please find the attached patch for the RE-SQL and modified SQL tests for
> check constraint node.
>
> For the table child nodes, *create table endpoint *with proper data is
> required in the JSON file.
> I have introduced one new parameter named *store_table_id* in the table
> create endpoint, so the created table ID will be stored for the rest of the
> scenarios
>

This breaks the type tests :-(

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
  2019-07-16 06:22 [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
  2019-07-16 08:35 ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Dave Page <[email protected]>
@ 2019-07-16 11:01   ` Khushboo Vashi <[email protected]>
  2019-07-17 12:25     ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Khushboo Vashi @ 2019-07-16 11:01 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi Dave,

On Tue, Jul 16, 2019 at 2:05 PM Dave Page <[email protected]> wrote:

> Hi
>
> On Tue, Jul 16, 2019 at 7:22 AM Khushboo Vashi <
> [email protected]> wrote:
>
>> Hi,
>>
>> Please find the attached patch for the RE-SQL and modified SQL tests for
>> check constraint node.
>>
>> For the table child nodes, *create table endpoint *with proper data is
>> required in the JSON file.
>> I have introduced one new parameter named *store_table_id* in the table
>> create endpoint, so the created table ID will be stored for the rest of the
>> scenarios
>>
>
> This breaks the type tests :-(
>
> Fixed.
Please find the attached updated patch.

Thanks,
Khushboo

> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Attachments:

  [application/octet-stream] resql_check_constraint_v1.patch (6.5K, 3-resql_check_constraint_v1.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql
new file mode 100644
index 00000000..e9985430
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/alter_check_constraint.sql
@@ -0,0 +1,9 @@
+-- Constraint: Chk_$%{}[]()&*^!@"'`\/#a
+
+-- ALTER TABLE testschema.tableforcon DROP CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a";
+
+ALTER TABLE testschema.tableforcon
+    ADD CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" CHECK (col1 > 1);
+
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforcon
+    IS 'Comment for alter';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql
new file mode 100644
index 00000000..9afc729b
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/create_check_constraint.sql
@@ -0,0 +1,10 @@
+-- Constraint: Chk_$%{}[]()&*^!@"'`\/#
+
+-- ALTER TABLE testschema.tableforcon DROP CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#";
+
+ALTER TABLE testschema.tableforcon
+    ADD CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" CHECK (col1 > 1)
+    NOT VALID;
+
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" ON testschema.tableforcon
+    IS 'Comment for create';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql
new file mode 100644
index 00000000..6f1fd8d3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/msql_check_constraint.sql
@@ -0,0 +1,6 @@
+ALTER TABLE testschema.tableforcon
+    RENAME CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#" TO "Chk_$%{}[]()&*^!@""'`\/#a";
+ALTER TABLE testschema.tableforcon
+    VALIDATE CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a";
+COMMENT ON CONSTRAINT "Chk_$%{}[]()&*^!@""'`\/#a" ON testschema.tableforcon
+    IS 'Comment for alter';
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
new file mode 100644
index 00000000..a5fb3671
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json
@@ -0,0 +1,56 @@
+{
+  "scenarios": [
+    {
+      "type": "create",
+      "name": "Create Table",
+      "endpoint": "NODE-table.obj",
+      "sql_endpoint": "NODE-table.sql_id",
+      "data": {
+        "name": "tableforcon",
+        "columns": [{
+          "name": "col1",
+          "cltype": "integer",
+          "is_primary_key": true
+        }],
+        "is_partitioned": false,
+        "schema": "testschema",
+        "spcname": "pg_default"
+      },
+      "store_table_id": true
+    },
+    {
+      "type": "create",
+      "name": "Create Check Constraint",
+      "endpoint": "NODE-check_constraint.obj",
+      "sql_endpoint": "NODE-check_constraint.sql_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#",
+        "comment": "Comment for create",
+        "consrc": "col1 > 1",
+        "connoinherit": false,
+        "convalidated": true
+      },
+      "expected_sql_file": "create_check_constraint.sql"
+    }, {
+      "type": "alter",
+      "name": "Alter Check Constraint",
+      "endpoint": "NODE-check_constraint.obj_id",
+      "sql_endpoint": "NODE-check_constraint.sql_id",
+      "msql_endpoint": "NODE-check_constraint.msql_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#a",
+        "convalidated": false,
+        "comment": "Comment for alter"
+      },
+      "expected_sql_file": "alter_check_constraint.sql",
+      "expected_msql_file": "msql_check_constraint.sql"
+    }, {
+      "type": "delete",
+      "name": "Drop Check Constraint",
+      "endpoint": "NODE-check_constraint.delete_id",
+      "data": {
+        "name": "Chk_$%{}[]()&*^!@\"'`\\/#a"
+      }
+    }
+  ]
+}
diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py
index 031b4f8e..5e8452e8 100644
--- a/web/regression/re_sql/tests/test_resql.py
+++ b/web/regression/re_sql/tests/test_resql.py
@@ -90,6 +90,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
             BaseTestGenerator.exclude_pkgs)
 
         for module in resql_module_list:
+            self.table_id = None
             module_path = resql_module_list[module]
             # Get the folder name based on server version number and
             # their existence.
@@ -159,6 +160,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                     options['did'] = int(self.server_information['db_id'])
                 elif arg == 'scid':
                     options['scid'] = int(self.schema_id)
+                elif arg == 'tid' and self.table_id:
+                    options['tid'] = int(self.table_id)
                 else:
                     if object_id is not None:
                         options[arg] = int(object_id)
@@ -220,6 +223,10 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                 resp_data = json.loads(response.data.decode('utf8'))
                 object_id = resp_data['node']['_id']
 
+                # Table child nodes require table id
+                if 'store_table_id' in scenario:
+                    self.table_id = object_id
+
                 # Compare the reverse engineering SQL
                 if not self.check_re_sql(scenario, object_id):
                     print(scenario['name'] + "... FAIL")
@@ -329,6 +336,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                                 object_id)
 
         params = urllib.parse.urlencode(scenario['data'])
+        params = params.replace('False', 'false').replace('True', 'true')
         url = msql_url + "?%s" % params
         response = self.tester.get(url,
                                    follow_redirects=True)


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
  2019-07-16 06:22 [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
  2019-07-16 08:35 ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Dave Page <[email protected]>
  2019-07-16 11:01   ` Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
@ 2019-07-17 12:25     ` Dave Page <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Page @ 2019-07-17 12:25 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Tue, Jul 16, 2019 at 12:01 PM Khushboo Vashi <
[email protected]> wrote:

> Hi Dave,
>
> On Tue, Jul 16, 2019 at 2:05 PM Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Tue, Jul 16, 2019 at 7:22 AM Khushboo Vashi <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached patch for the RE-SQL and modified SQL tests for
>>> check constraint node.
>>>
>>> For the table child nodes, *create table endpoint *with proper data is
>>> required in the JSON file.
>>> I have introduced one new parameter named *store_table_id* in the table
>>> create endpoint, so the created table ID will be stored for the rest of the
>>> scenarios
>>>
>>
>> This breaks the type tests :-(
>>
>> Fixed.
> Please find the attached updated patch.
>
> Thanks,
> Khushboo
>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-07-17 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 06:22 [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node Khushboo Vashi <[email protected]>
2019-07-16 08:35 ` Dave Page <[email protected]>
2019-07-16 11:01   ` Khushboo Vashi <[email protected]>
2019-07-17 12:25     ` Dave Page <[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