Skip to content

geometric_type false positive when enum name matches pattern #432

@modosc

Description

@modosc

i have a postgres enum type with point in the name. this column is falsely being identified with @geometric_type=RGeo::Feature::Geometry even though @geographic=false:

#<ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumn:0x0000000163a36880
 @collation=nil,
 @comment=nil,
 @default=nil,
 @default_function=nil,
 @generated="",
 @geographic=false,
 @geometric_type=RGeo::Feature::Geometry,
 @has_m=false,
 @has_z=false,
 @identity=nil,
 @name="waypoint_type",
 @null=false,
 @serial=nil,
 @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x0000000163f12e58 @limit=nil, @precision=nil, @scale=nil, @sql_type="waypoint_type", @type=:enum>,
 @srid=0>

and this causes a weird interplay with annotaterb which then adds the following to my model:

#  waypoint_type                                                        :enum             not null, geometry, 0

i believe the issue is in this code:

elsif sql_type_metadata.sql_type =~ /geography|geometry|point|linestring|polygon/i
# A geometry column with no geometry_columns entry.
# @geometric_type = geo_type_from_sql_type(sql_type)
build_from_sql_type(sql_type_metadata.sql_type)
end

it seems like this would fix it

elsif sql_type_metadata.type != :enum && sql_type_metadata.sql_type =~ /geography|geometry|point|linestring|polygon/i

i'm going to open a pr and try it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions