Permalink
Browse files

remove ability to handle ranges and arrays for equals

  • Loading branch information...
1 parent 536eeaf commit fe519d8a31e091d83cd9b7bf11215c6f4ccb0a30 @binarylogic binarylogic committed Mar 7, 2011
View
7 lib/searchlogic.rb
@@ -1,6 +1,5 @@
require "searchlogic/core_ext/proc"
require "searchlogic/core_ext/object"
-require "searchlogic/active_record/association_proxy"
require "searchlogic/active_record/consistency"
require "searchlogic/active_record/named_scope_tools"
require "searchlogic/named_scopes/base"
@@ -25,12 +24,6 @@
Object.send(:include, Searchlogic::CoreExt::Object)
module ActiveRecord # :nodoc: all
- module Associations
- class AssociationProxy
- include Searchlogic::ActiveRecord::AssociationProxy
- end
- end
-
class Base
class << self; include Searchlogic::ActiveRecord::Consistency; end
end
View
20 lib/searchlogic/active_record/association_proxy.rb
@@ -1,20 +0,0 @@
-module Searchlogic
- module ActiveRecord
- module AssociationProxy
- def self.included(klass)
- klass.class_eval do
- alias_method_chain :send, :searchlogic
- end
- end
-
- def send_with_searchlogic(method, *args, &block)
- # create the scope if it doesn't exist yet, then delegate back to the original method
- if !proxy_respond_to?(method) && proxy_reflection.macro != :belongs_to && !proxy_reflection.options[:polymorphic] && proxy_reflection.klass.condition?(method)
- proxy_reflection.klass.send(method, *args, &block)
- end
-
- send_without_searchlogic(method, *args, &block)
- end
- end
- end
-end
View
10 lib/searchlogic/named_scopes/column_conditions.rb
@@ -115,7 +115,7 @@ def create_primary_condition(column_name, condition)
scope_options = case condition.to_s
when /^equals/
- scope_options(condition, column, lambda { |a| attribute_condition("#{table_name}.#{column.name}", a) }, :skip_conversion => skip_conversion)
+ scope_options(condition, column, "#{table_name}.#{column.name} = ?", :skip_conversion => skip_conversion)
when /^does_not_equal/
scope_options(condition, column, "#{table_name}.#{column.name} != ?", :skip_conversion => skip_conversion)
when /^less_than_or_equal_to/
@@ -180,9 +180,9 @@ def scope_options(condition, column, sql, options = {})
values.flatten!
values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
- scope_sql = values.collect { |value| sql.is_a?(Proc) ? sql.call(value) : sql }.join(join_word)
+ scope_sql = values.collect { |value| sql }.join(join_word)
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
+ {:conditions => [scope_sql, *values]}
end
else
{}
@@ -192,9 +192,7 @@ def scope_options(condition, column, sql, options = {})
searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values|
values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
- scope_sql = sql.is_a?(Proc) ? sql.call(*values) : sql
-
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
+ {:conditions => [sql, *values]}
}
end
end
View
2 spec/searchlogic/named_scopes/column_conditions_spec.rb
@@ -19,8 +19,6 @@
it "should have equals" do
(5..7).each { |age| User.create(:age => age) }
User.age_equals(6).all.should == User.find_all_by_age(6)
- User.age_equals(5..6).all.should == User.find_all_by_age(5..6)
- User.age_equals([5, 7]).all.should == User.find_all_by_age([5, 7])
end
it "should have does not equal" do

0 comments on commit fe519d8

Please sign in to comment.