public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
Date: Tue, 16 Jul 2019 16:31:24 +0530
Message-ID: <CAFOhELdj7mzZZsLCArB-UM+aJ9c_iywg1i0zSNgbDvYvBgL7rg@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoyXS6oFFrr6nFGy3ZxnqM2gqeDmm0bxZwB97medjL9A=A@mail.gmail.com>
References: <CAFOhELePnGgBQnfowrkabLHauGBiXO9xNGM_hmCZ766PUPmtFQ@mail.gmail.com>
<CA+OCxoyXS6oFFrr6nFGy3ZxnqM2gqeDmm0bxZwB97medjL9A=A@mail.gmail.com>
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)
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][Patch] - RE-SQL and modified SQL tests for Check Constraint node
In-Reply-To: <CAFOhELdj7mzZZsLCArB-UM+aJ9c_iywg1i0zSNgbDvYvBgL7rg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox