Skip to content

MULTI geoms are bound to sql separately  #79

@nikolai-b

Description

@nikolai-b

I'd expect multi geoms to be bound / cast (?) as a multi geoms in active record:

multi_geom = RGeo::Geos.factory.parse_wkt("MULTIPOLYGON (((0 0, 0 1, 1 1, 0 0)),((1 1, 0 0, 0 1, 1 1)))")
ApplicationRecord.send(:quote_bound_value, multi_geom)
=> "'00200000030000000000000001000000040000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff000000000000000000000000000000000000000000000','00200000030000000000000001000000043ff00000000000003ff00000000000000000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff0000000000000'"

To get a proper multi-geom I have to wrap it in an array

ApplicationRecord.send(:quote_bound_value, [multi_geom])
 => "'00200000060000000000000002000000000300000001000000040000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff000000000000000000000000000000000000000000000000000000300000001000000043ff00000000000003ff00000000000000000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff0000000000000'" 

This is because AR checks if a method responds to map here

Not sure how best to solve this without some nasty monkey patch

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