I created GEOT-7746 <https://osgeo-org.atlassian.net/browse/GEOT-7746> and
the cause appears to be due to a collision between the values in
java.sql.Types and the org.geotools.geometry.jts.Geometries. For the
GeoPackage module this causes an issue where the MultiLineString columns
are given the wrong SQL Type (TEXT instead of MULTILINESTRING) as the
GeoPkgDialect has a type override for Types.CLOB to make it a TEXT.  Both
CLOB and MULTILINESTRING share the sqlType 2005. Other Geometries sqlTypes
also collide with java.sql.Types, but are not causing issues on GeoPackage
generation.

Either way, I propose changing the sqlTypes for the Geometries to an
integer not used by the java.sql.Types  (like 12005 instead of 2005) and
writing a test to ensure they don't collide:

@Test
public void testNoJavaSqlTypeCollisions() throws IllegalAccessException {
    Field[] fields = java.sql.Types.class.getFields();
    for (Geometries type : Geometries.values()) {
        int geometrySqlType = type.getSQLType();
        for (Field field : fields) {
            if (field.getType() == int.class) {
                int javaSqlType = field.getInt(null);
                assertTrue(
                        "Collision detected: Geometries." + type.name()
                                + " matches java.sql.Types."
                                + field.getName(),
                        geometrySqlType != javaSqlType);
            }
        }
    }
}


Michael Kandar

michael.kan...@gmail.com
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to