Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix Visitor pattern thanks dockyard/postgres_ext@2ee134c

  • Loading branch information...
commit 04d2bdddf9d717b930a3a83586cc005f1d2ade77 1 parent 3b981c1
@kbrock kbrock authored
View
2  lib/postgres_gis/arel/visitors/to_sql.rb
@@ -1,7 +1,7 @@
require 'arel/visitors/to_sql'
module Arel
module Visitors
- class ToSql
+ class Visitor
private
def visit_Arel_Nodes_GisOverlap o
"st_distance(#{visit o.left},#{visit o.right},0)"
View
16 spec/arel/point_spec.rb
@@ -17,17 +17,15 @@ class Place < ActiveRecord::Base
Object.send(:remove_const, :Place)
end
- describe 'quoting IPAddr in sql statement' do
- it 'properly converts IPAddr to quoted strings when passed as an argument to a where clause' do
+ describe 'converting polygons in sql statement' do
+ it 'properly converts Point to sql format when passed as an argument to a where clause' do
Place.where(:address => GeometryFactory.point).to_sql.should include("SRID=4326;POINT(1 2)")
end
end
- # describe 'cotained with (<<) operator' do
- # it 'converts Arel contained_within statemnts to <<' do
- # arel_table = IpAddress.arel_table
-
- # arel_table.where(arel_table[:address].contained_within(IPAddr.new('127.0.0.1/24'))).to_sql.should match /<< '127.0.0.0\/24'/
- # end
- # end
+ it 'works with count (and other predicates)' do
+ Place.create(address: GeometryFactory.point)
+ arel_table = Place.arel_table
+ Place.where(arel_table[:address].eq(GeometryFactory.point)).count.should eq 1
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.