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

Text type columns with default value don't export properly in MYSQL #1554

Closed shubham-yb closed 1 year ago

shubham-yb commented 1 year ago

Hi Team, When we have default values assigned for text type columns in MYSQL, it does not export as expected and thus fails while import. This was also observed for BLOB type columns which export as bytea.

Source schema:

drop table if exists text_types;

CREATE TABLE text_types (
                                               id int, 
                                               tt TINYTEXT DEFAULT ('c'), 
                                               te TEXT DEFAULT ('abc'), 
                                               mt MEDIUMTEXT DEFAULT ('abc'), 
                                               lt LONGTEXT DEFAULT ('abc')
                                              );

insert into text_types(id) values(1);

desc text_types;

Exported schema:

CREATE TABLE text_types (
        id numeric(10),
        tt text DEFAULT _utf8mb4\'c\',
        te text DEFAULT _utf8mb4\'abc\',
        mt text DEFAULT _utf8mb4\'abc\',
        lt text DEFAULT _utf8mb4\'abc\'
) ;

This in turn errors out.

ERROR: syntax error at or near "\" (SQLSTATE 42601)

Thank You for your help.

shubham-yb commented 1 year ago

cc: @darold

darold commented 1 year ago

Commit 6b8857b fixes this issue.