rgeo / rgeo-activerecord

RGeo ActiveRecord extensions and tools for spatial connection adapters
Other
89 stars 64 forks source link

Construct an Arel node instead message #41

Closed printercu closed 3 years ago

printercu commented 7 years ago

Hi! I'm trying to investigate why RGeo features are supported in simple arel functions like = but not as arguments for functions:

2.3.3 (main):0[22] > location = Building.arel_table[:location];
2.3.3 (main):0[23] > point = RGeo::Geographic.spherical_factory(srid: 4326).point(1, 2);
2.3.3 (main):0[24] > location.eq(point).to_sql
=> "\"buildings\".\"location\" = '0020000001000010e63ff00000000000004000000000000000'"
2.3.3 (main):0[25] > location.st_function('ST_DWithin', point, 1, [false, true, true, false]).to_sql
Arel::Visitors::UnsupportedVisitError: Unsupported argument type: RGeo::Geographic::SphericalPointImpl. Construct an Arel node instead.

I'm using point.to_s in function and it wraps value with ST_GeomFromEWKT. Is it the right way or should RGeo features be used in queries without .to_s?

keithdoggett commented 3 years ago

Fixed by #60