mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add Reverse Engineered SQL tests for Constraints. Fixes #4475
This commit is contained in:
committed by
Dave Page
parent
710d520631
commit
8168f623c4
@@ -29,6 +29,7 @@ Housekeeping
|
||||
| `Issue #4468 <https://redmine.postgresql.org/issues/4468>`_ - Add Reverse Engineered SQL tests for Types.
|
||||
| `Issue #4471 <https://redmine.postgresql.org/issues/4471>`_ - Add Reverse Engineered SQL tests for FTS Parsers.
|
||||
| `Issue #4469 <https://redmine.postgresql.org/issues/4469>`_ - Add Reverse Engineered SQL tests for Sequences.
|
||||
| `Issue #4475 <https://redmine.postgresql.org/issues/4475>`_ - Add Reverse Engineered SQL tests for Constraints.
|
||||
|
||||
Bug fixes
|
||||
*********
|
||||
|
@@ -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';
|
@@ -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';
|
@@ -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';
|
@@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user