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

Geospatial field issue #1755

Closed LucaGalvagno closed 3 months ago

LucaGalvagno commented 3 months ago

Hello, I was experiencing a problem when using WKT format export from Oracle, that I solved modifying the code of the file Ora2Pg.pm . The problem I think was caused by the fact that ins subroutine format_data_row is evaluating if there is at least a gemotry field with : $has_geom = 1 if (grep(/^(SDOGEOMETRY|ST|STGEOM_)/, @$src_data_types)); That was causing of having all the fields, of a table with at least a geometry in that way : $row->[$idx] = "ST_Geometry('" . $row->[$idx] . "', $self->{spatial_srid}{$table}->[$idx])"; In order to avoid such behaviour I added the evaluation of has_geom variable inside the "for" cycle that is checcking all data types of the routine format_data_row : for (my $idx = 0; $idx <= $#{$data_types}; $idx++) { if ($src_data_types->[$idx] =~ /SDO_GEOMETRY/i) { $has_geom = 1 }else{ $has_geom = 0 } In attach the file.

Ora2Pg.pm.txt

LucaGalvagno commented 3 months ago

Hello, I forgot to mention that I was using Ora2pg 24.2 .

darold commented 3 months ago

Right, table data export when there is a geometry column was totally broken, commit b7912464e fixes this issue.