diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-24 13:02:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-24 13:02:50 +0000 |
commit | 93ec1303779a238754c87572e6e96d32133cee86 (patch) | |
tree | bb0ad7b112b0dc52c7ab44936a1dbbb1ffabea96 /activerecord/lib | |
parent | 0725498d6f37c93a697468d3f5d4743861b84542 (diff) | |
download | rails-93ec1303779a238754c87572e6e96d32133cee86.tar.gz rails-93ec1303779a238754c87572e6e96d32133cee86.tar.bz2 rails-93ec1303779a238754c87572e6e96d32133cee86.zip |
Fixed that the dynamic finders didnt treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@488 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c1cedbcf61..0309f03a5a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -668,7 +668,9 @@ module ActiveRecord #:nodoc: if method_name =~ /find_(all_by|by)_([_a-z]+)/ finder, attributes = ($1 == "all_by" ? :find_all : :find_first), $2.split("_and_") attributes.each { |attr_name| super unless column_methods_hash[attr_name.intern] } - conditions = attributes.collect { |attr_name| "#{attr_name} = ? "}.join(" AND ") + + attr_index = -1 + conditions = attributes.collect { |attr_name| attr_index += 1; "#{attr_name} #{arguments[attr_index] ? "=" : "IS"} ? " }.join(" AND ") send(finder, [conditions, *arguments[0...attributes.length]], *arguments[attributes.length..-1]) else super |