claeis / ili2db

interlis import/export to relational databases
30 stars 30 forks source link

Unique constraints are not generated #493

Closed yesidpol closed 12 months ago

yesidpol commented 2 years ago

Unique constraints are not generated in the databases. I could identify that the version 3.12.3 was the last one that generated unique constraints.

I tested these versions:

version generate uniques?
ili2gpkg-3.12.2 yes
ili2gpkg-3.12.3 yes
ili2gpkg-4.0.0 no
ili2gpkg-4.6.1 no
ili2gpkg-4.9.0 no
-- --
ili2pg-3.11.4 yes
ili2pg-3.12.3 yes
ili2pg-4.0.0 no
ili2pg-4.3.3 no
ili2pg-4.4.3 no
ili2pg-4.9.0 no

The arguments that I used:

--coalesceCatalogueRef --coalesceMultiLine --smart2Inheritance --createUnique --beautifyEnumDispName --createFkIdx --schemaimport --createFk --createEnumTabs --defaultSrsCode 3116 --coalesceMultiSurface --createNumChecks --strokeArcs  --createGeomIdx --createMetaInfo

and the model

INTERLIS 2.3;

MODEL ModelC (de) AT "http://github.com" VERSION "2022_10_25" = 
    TOPIC TheTopic = 
        CLASS TheClass = 
            aNumber: 0 .. 10;
            UNIQUE aNumber;
        END TheClass;
    END TheTopic;
END ModelC.
signedav commented 1 year ago

I can confirm that.

And having a geometry it does create the unique constraint.

INTERLIS 2.3;

MODEL ModelC (de) AT "http://github.com" VERSION "2022_10_25" = 
    IMPORTS GeometryCHLV95_V1;
    TOPIC TheTopic = 

        CLASS TheClass = 
            aNumber: 0 .. 10;
            UNIQUE aNumber;
        END TheClass;

        CLASS TheClassWithGeometry = 
            aNumber: 0 .. 10;
            Geometrie: MANDATORY GeometryCHLV95_V1.Coord2;
            UNIQUE aNumber;
        END TheClassWithGeometry;
    END TheTopic;
END ModelC.

(TheClassWithGeometry with CREATE UNIQUE INDEX theclasswithgeometry_anumber_key ON "theclasswithgeometry" USING btree ("anumber"); and TheClass withouth it)

Philippluca commented 1 year ago

Notiz für den Fix: Aktuelle werden die UNIQUE Indices nur generiert, sofern für das referenzierte Attribut auch ein zugewiesener epgsCode gefunden wird. Der Fehler passiert auf Zeile hier.