darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.03k stars 343 forks source link

Extra comma "," in parsing of >1 check constraints in MYSQL #1527

Closed shubham-yb closed 2 years ago

shubham-yb commented 2 years ago

Hi Team,

If we have a table which has more than one check constraints, bar the constraint which parses last, the rest export with an extra comma "," in their DDL and thus fails while importing, irrespective of other constraints on that table.

Example schema 1:

drop table if exists xyz;

create table xyz(id int ,name varchar(20),name2 varchar(20), check(id>10),unique(name2),check(name="abc"));

Exported schema:

CREATE TABLE xyz (
    id numeric(10),
    name varchar(20),
    name2 varchar(20),
) ;
ALTER TABLE xyz ADD UNIQUE (name2);
ALTER TABLE xyz ADD CONSTRAINT xyz_chk_1 CHECK ((id > 10),);
ALTER TABLE xyz ADD CONSTRAINT xyz_chk_2 CHECK ((name = 'abc'));

Example schema 2:

drop table if exists abc;

create table abc(id int,name varchar(20),name2 varchar(20),check(id>10),check(name2="xyz"),check(name="abc"));

Exported schema:

CREATE TABLE abc (
    id numeric(10),
    name varchar(20),
    name2 varchar(20)
) ;
ALTER TABLE abc ADD CONSTRAINT abc_chk_1 CHECK ((id > 10),);
ALTER TABLE abc ADD CONSTRAINT abc_chk_2 CHECK ((name2 = 'xyz'),);
ALTER TABLE abc ADD CONSTRAINT abc_chk_3 CHECK ((name = 'abc'));

Please notice the extra comma "," at the end of the Alter table statements.

Thank You for your help.

darold commented 2 years ago

Commit db653f2 fixes this issue.