In order to determine the properties of a geometry column, the OID::Spatial#parse_sql_type method is called in the SchemaStatements#initialize_type_map method for geometry types. This method parses a sql_type (ex. "geometry(Polygon,4326)") and derives the geo_type, srid, has_z, has_m, and geographic properties from the string.
The problem is that after a join, sql_type comes in as "". This makes it impossible to determine any properties from it and the default properties are passed into the OID::Spatial constructor which can cause unexpected geometry types to appear.
Here is the place where the sql_type comes in.
|
map.register_type(geo_type) do |_, _, sql_type| |
|
# sql_type is a string that comes from the database definition |
|
# examples: |
|
# "geometry(Point,4326)" |
|
# "geography(Point,4326)" |
|
# "geometry(Polygon,4326) NOT NULL" |
|
# "geometry(Geography,4326)" |
|
geo_type, srid, has_z, has_m, geographic = OID::Spatial.parse_sql_type(sql_type) |
|
OID::Spatial.new(geo_type: geo_type, srid: srid, has_z: has_z, has_m: has_m, geographic: geographic) |
This is likely some sort of upstream issue where the data in a join is not being passed properly.
The current workaround is to register an attribute on the target table (described in #334).
In order to determine the properties of a geometry column, the
OID::Spatial#parse_sql_typemethod is called in theSchemaStatements#initialize_type_mapmethod for geometry types. This method parses asql_type(ex. "geometry(Polygon,4326)") and derives thegeo_type,srid,has_z,has_m, andgeographicproperties from the string.The problem is that after a join,
sql_typecomes in as "". This makes it impossible to determine any properties from it and the default properties are passed into theOID::Spatialconstructor which can cause unexpected geometry types to appear.Here is the place where the
sql_typecomes in.activerecord-postgis-adapter/lib/active_record/connection_adapters/postgis/schema_statements.rb
Lines 99 to 107 in 95be29d
This is likely some sort of upstream issue where the data in a join is not being passed properly.
The current workaround is to register an
attributeon the target table (described in #334).