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
978 stars 341 forks source link

[Oracle] Data is not getting dumped properly for a table named `"number"` #1769

Closed priyanshi-yb closed 2 months ago

priyanshi-yb commented 2 months ago

Hi team, I am observing that data for a table having name as "number" (reserved word in Oracle) is not getting dumped properly for ex -

create table "number"(id int PRIMARY KEY);
insert into "number" values(0);
insert into "number" values(1);
insert into "number" values(2);
insert into "number" values(3);
insert into "number" values(4);

this is dumped as

COPY number (id) FROM STDIN;
f
t
2
3
4
\.

where 0 and 1 are getting converted to f and t. And while we insert this data in PG it is failing with an error

ERROR: invalid input syntax for type numeric: "f"

Can someone please look into this issue and let me know if there is anything I am missing?

Thanks! CC: @darold

darold commented 2 months ago

I guess you have also set REPLACE_AS_BOOLEAN for this column?

priyanshi-yb commented 2 months ago

Hi @darold, no I haven't set this config option at all.

darold commented 2 months ago

And MODIFY_TYPE?

priyanshi-yb commented 2 months ago

No, not that as well. Also, FWIW this is converted schema dumped

CREATE TABLE number (
        id numeric(38) NOT NULL,
        PRIMARY KEY (id)
) ;

where the type is numeric only for this column.

priyanshi-yb commented 2 months ago

@darold , I also had other table in my oracle schema which also had INT column but the data for that is getting dumped properly with that config

CREATE TABLE user_table (
    id INT PRIMARY KEY,
    email VARCHAR(255),
    status VARCHAR(50) DEFAULT 'active'
);
INSERT INTO user_table VALUES (1, 'user1@example.com', 'active');
INSERT INTO user_table VALUES (2, 'user2@example.com', 'active');
INSERT INTO user_table VALUES (3, 'user3@example.com', 'active');
INSERT INTO user_table VALUES (4, 'user4@example.com', 'active');
INSERT INTO user_table VALUES (5, 'user5@example.com', 'active');
INSERT INTO user_table VALUES (6, 'user6@example.com', 'active');
INSERT INTO user_table VALUES (7, 'user7@example.com', 'active');
INSERT INTO user_table VALUES (8, 'user8@example.com', 'active');

data dumped with that same config used for this table -

COPY user_table (id,email,status) FROM STDIN;
1   user1@example.com   active
2   user2@example.com   active
3   user3@example.com   active
4   user4@example.com   active
5   user5@example.com   active
6   user6@example.com   active
7   user7@example.com   active
8   user8@example.com   active
\.

converted schema -

CREATE TABLE user_table (
    id numeric(38) NOT NULL,
    email varchar(255),
    status varchar(50) DEFAULT 'active',
    PRIMARY KEY (id)
) ;

so it looks like something with this table name "number", I believe.

darold commented 2 months ago

Commit 0217c3f fixes this issue.