From e7a65d786f44ff0dd1712e16571098ef01a27d1e Mon Sep 17 00:00:00 2001 From: priyanshi-yb Date: Wed, 4 Dec 2024 20:46:39 +0530 Subject: [PATCH] added tests and validation in pg --- .../pg/constraints/pg_constraints_automation.sql | 16 +++++++++------- migtests/tests/pg/constraints/validate | 6 +++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/migtests/tests/pg/constraints/pg_constraints_automation.sql b/migtests/tests/pg/constraints/pg_constraints_automation.sql index 4f70492627..d7929263c1 100644 --- a/migtests/tests/pg/constraints/pg_constraints_automation.sql +++ b/migtests/tests/pg/constraints/pg_constraints_automation.sql @@ -39,17 +39,19 @@ drop table if exists check_test; CREATE TABLE check_test ( ID serial primary key, first_name varchar(255) NOT NULL, + middle_name varchar(255) not null, last_name varchar(255), Age int, CHECK (Age>=18) ); -insert into check_test (first_name, last_name, age) values ('Modestine', 'MacMeeking', 20); -insert into check_test (first_name, last_name, age) values ('Genna', 'Kaysor', 50); -insert into check_test (first_name, last_name, age) values ('Tess', 'Wesker', 56); -insert into check_test (first_name, last_name, age) values ('Magnum', 'Danzelman', 89); -insert into check_test (first_name, last_name, age) values ('Mitzi', 'Pidwell', 34); -insert into check_test (first_name, last_name, age) values ('Milzie', 'Rohlfing', 70); - +insert into check_test (first_name, middle_name, last_name, age) values ('Modestine', '', 'MacMeeking', 20); +insert into check_test (first_name, middle_name, last_name, age) values ('Genna', '', 'Kaysor', 50); +insert into check_test (first_name, middle_name, last_name, age) values ('Tess', '', 'Wesker', 56); +insert into check_test (first_name, middle_name, last_name, age) values ('Magnum', '', 'Danzelman', 89); +insert into check_test (first_name, middle_name, last_name, age) values ('Mitzi', '', 'Pidwell', 34); +insert into check_test (first_name, middle_name, last_name, age) values ('Milzie', '', 'Rohlfing', 70); + +ALTER TABLE check_test ADD CONSTRAINT not_valid_cons CHECK(middle_name<>'') NOT VALID; drop table if exists default_test; diff --git a/migtests/tests/pg/constraints/validate b/migtests/tests/pg/constraints/validate index 7199571d27..82d036ded2 100755 --- a/migtests/tests/pg/constraints/validate +++ b/migtests/tests/pg/constraints/validate @@ -29,7 +29,11 @@ QUERIES_CHECK = { 'code': "23505" }, 'CHECK_CONDITION': { - 'query': "insert into check_test (id, first_name, last_name, age) values (7, 'Tom', 'Stewan', 15);", + 'query': "insert into check_test (id, first_name, middle_name, last_name, age) values (7, 'Tom', 'abc', 'Stewan', 15);", + 'code': "23514" + }, + 'CHECK_CONDITION_NOT_VALID': { + 'query': "insert into check_test (id, first_name, middle_name, last_name, age) values (7, 'Tom', '', 'Stewan', 52);", 'code': "23514" }, 'FOREIGN_CHECK': {