Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AR type cast to mirror quoting #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikolai-b
Copy link

It seems wrong that

SpatialModel.where("ST_DWITHIN(latlon_geo, ?, 500)", geographic_factory.point(-72.099, 42.099)).to_sql

uses the EWKB format but when the query is actually executed it uses to_s which uses the WKT without passing any SRID. This was causing me issues for me with preprepared statements but I couldn't create a simple text. I do think this gem should pass the SRID of bindings though.

I'm not very happy with the test I've written here. I looked .values_for_queries or looking at the arel but the binds haven't been type_cast at this point so I've used explain.

Copy link
Member

@keithdoggett keithdoggett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikolai-b thanks for the PR! I think this looks good. Was this only effecting prepared geometries? I thought there was some work done recently that added the SRID to the generated string in the rgeo-activerecord gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants