Permalink
Browse files

Make sure that InfixOperation can be visited by Arel

Fixes #101 by making sure Arel alias is in place
Based on a similar fix for activerecord-hackery/squeel#122
  • Loading branch information...
1 parent 165fc64 commit 3039ba615cee79fb022a8275490487e8c30d9847 @nertzy nertzy committed Apr 5, 2013
Showing with 12 additions and 0 deletions.
  1. +1 −0 lib/pg_search.rb
  2. +10 −0 lib/pg_search/extensions/arel.rb
  3. +1 −0 pg_search.gemspec
View
@@ -2,6 +2,7 @@
require "active_support/concern"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/string/strip"
+require "pg_search/extensions/arel"
module PgSearch
autoload :Configuration, "pg_search/configuration"
@@ -0,0 +1,10 @@
+require "arel/visitors/depth_first"
+
+# Workaround for https://github.com/Casecommons/pg_search/issues/101
+# Based on the solution from https://github.com/ernie/squeel/issues/122
+Arel::Visitors::DepthFirst.class_eval do
+ unless method_defined?(:visit_Arel_Nodes_InfixOperation)
+ alias :visit_Arel_Nodes_InfixOperation :binary
+ end
+end
+
View
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activerecord', '>=3.1'
s.add_dependency 'activesupport', '>=3.1'
+ s.add_dependency 'arel'
s.add_development_dependency 'rake'
s.add_development_dependency 'rdoc'

0 comments on commit 3039ba6

Please sign in to comment.