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

Bug Issue migrating data in json column #1745

Closed gael-efluid closed 3 months ago

gael-efluid commented 4 months ago

Hello, We have an issue in our data from Oracle database using ora2pg (v24.1 [edit]reproduced also on the 24.2[/edit]). We are currently using PG v14.8.

We found that data stored as key in json colums and with the text "borneInferieureIncluse" are changed by the tool to "borneInfinityerieureIncluse"

You can easily reproduce through the following steps

creation of the test table

CREATE TABLE TEST_JSON
(
  ID                  VARCHAR2(25 BYTE),
  JSONDATA            CLOB
);

insertion in the table of the data containing Inf

insert into TEST_JSON(id,jsondata) values(2,'{"valeurs":{"0":{"1111Inf2222":1}}}');
insert into TEST_JSON(id,jsondata) values(3,'{"valeurs":{"0":{"typeComparaison":1,"critere":"$CRITERE275155$3","borneSuperieureIncluse":false,"borneInferieureIncluse":true,"type":"INTERVALLE_QUANTITE","borneInferieure":{"valeur":0.0},"borneSuperieure":{"valeur":3.0}}},"description":"(&(0))"}');
commit;

On ora2pg, you configure the file config/ora2pg.conf with

MODIFY_TYPE TEST_JSON:JSONDATA:JSON

extraction of the table ddl through ora2pg

ora2pg -p -t TABLE -o table.sql -b ./schema/tables -c ./config/ora2pg.conf -a TABLE[TEST_JSON]

creation of the table under PG playing the ddl of the table TEST_JSON

psql -d **** -U ***-p 5432 -f schema/tables/table.sql

migration of the data through ora2pg

ora2pg -c config/ora2pg.conf -t COPY -a TABLE[TEST_JSON]

Select the migrated data

select jsondata from TEST_JSON;
{"valeurs":{"0":{"1111Infinity2222":1}}}
{"valeurs":{"0":{"typeComparaison":1,"critere":"$CRITERE275155$3","borneSuperieureIncluse":false,"borneInfinityerieureIncluse":true,"type":"INTERVALLE_QUANTITE","borneInfinityerieure":{"valeur":0.0},"borneSuperieure":{"valeur":3.0}}},"description":"(&(0))"}
gael-efluid commented 4 months ago

Apparently it seems that it comes from the correction of this issue : https://github.com/darold/ora2pg/issues/723 https://github.com/darold/ora2pg/commit/088b748f0880a34b59e50e1a68c7a2ac0418249b

darold commented 3 months ago

Commit a5ae177 might fix this issue.