You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to create scopes on ActiveRecord models from the SpatialNamedFunctions. This would be in an optional module a user could include into their ActiveRecord model and it would allow access to these scopes.
This would make the SpatialNamedFunctions more accessible for users that are unfamiliar with Arel.
It seems that the above example using st_contains
is in fact a simple case. Looking at
the content of the tests (rg arel_table test/) we
can see that sometimes we use where like in the
example, sometimes we use find_by.
Also the example takes the simple case of st_contains,
but st_distance for instance, should then be chained
with a comparator (ex: .lt(2)) which makes the signature
way more complicated.
Here's an example signature that would contain enough info:
Location.st_distance(:geom,pt,->(x){x.lt(2)})
I think it becomes harder to understand. The one below
may already be a bit simpler:
Location.st(:geom,->(x){x.st_distance(pt).lt(2)})
But I feel like we are not really getting an advantage
with the new writing. Also these two examples are not
letting the user choose between where and find_by,
we assume one of them, otherwise we'd need even one
more argument.
With that said, I do not think that I have a convincing
design yet for a generic solution. Someone has something
better to offer? @heka1024 looking at you! Would you be
our champion on this?
It should be possible to create scopes on
ActiveRecord
models from theSpatialNamedFunctions
. This would be in an optional module a user couldinclude
into theirActiveRecord
model and it would allow access to these scopes.This would make the
SpatialNamedFunctions
more accessible for users that are unfamiliar withArel
.This would allow you to go from this:
to:
The text was updated successfully, but these errors were encountered: