Permalink
Browse files

fix Visitor pattern thanks DavyJonesLocker/postgres_ext@2ee134c

  • Loading branch information...
kbrock committed Dec 17, 2012
1 parent 3b981c1 commit 04d2bdddf9d717b930a3a83586cc005f1d2ade77
Showing with 8 additions and 10 deletions.
  1. +1 −1 lib/postgres_gis/arel/visitors/to_sql.rb
  2. +7 −9 spec/arel/point_spec.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
@@ -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

0 comments on commit 04d2bdd

Please sign in to comment.