Skip to content

Commit

Permalink
added tests and validation in pg
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshi-yb committed Dec 4, 2024
1 parent 9c3b0fa commit e7a65d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 9 additions & 7 deletions migtests/tests/pg/constraints/pg_constraints_automation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion migtests/tests/pg/constraints/validate
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down

0 comments on commit e7a65d7

Please sign in to comment.