Browse files

* Fix bug to give priority to local columns.

  • Loading branch information...
1 parent 4856890 commit b273d29be25a71d2885634ced573a525ad742ca6 @binarylogic committed Jul 31, 2009
View
4 CHANGELOG.rdoc
@@ -1,3 +1,7 @@
+== 2.2.2 released 2009-07-31
+
+* Fix bug to give priority to local columns.
+
== 2.2.1 released 2009-07-30
* Use ::ActiveRecord instead of ActiveRecord to avoid a name conflict since ActiveRecord is a module within Searchlogic.
View
2 lib/searchlogic/named_scopes/association_conditions.rb
@@ -22,7 +22,7 @@ def association_condition?(name)
end
def method_missing(name, *args, &block)
- if details = association_condition_details(name)
+ if !local_condition?(name) && details = association_condition_details(name)
create_association_condition(details[:association], details[:condition], args)
send(name, *args)
else
View
10 lib/searchlogic/named_scopes/conditions.rb
@@ -67,12 +67,16 @@ def primary_condition_name(name)
# Is the name of the method a valid condition that can be dynamically created?
def condition?(name)
- return false if name.blank?
- scope_names = scopes.keys.reject { |k| k == :scoped }
- scope_names.include?(name.to_sym) || !condition_details(name).nil?
+ local_condition?(name)
end
private
+ def local_condition?(name)
+ return false if name.blank?
+ scope_names = scopes.keys.reject { |k| k == :scoped }
+ scope_names.include?(name.to_sym) || !condition_details(name).nil?
+ end
+
def method_missing(name, *args, &block)
if details = condition_details(name)
create_condition(details[:column], details[:condition], args)
View
3 spec/named_scopes/conditions_spec.rb
@@ -270,5 +270,8 @@
it "should have priorty to columns over conflicting association conditions" do
Company.users_count_gt(10)
+ User.create
+ User.company_id_null.count.should == 1
+ User.company_id_not_null.count.should == 0
end
end

0 comments on commit b273d29

Please sign in to comment.