Permalink
Browse files

Fixes where issue with hashed wheres and array values

Closes #111
  • Loading branch information...
1 parent eae9144 commit add4d40008dd159dd7d88bdf5320f12523ce56bd @danmcclain danmcclain committed Feb 3, 2014
View
@@ -1,3 +1,8 @@
+## 2.2.1 (unreleased)
+
+ * Fixes an issue with `where(table: { column: [] })` was not properly
+ converting the where clause to an equality instead of an `IN`
+ predicate (#111) - Dan McClain
## 2.2.0
* Adds Arel predications for `ANY` and `ALL` - Dan McClain
@@ -8,7 +8,7 @@ def self.build(attribute, value)
case value
when Array
engine = attribute.relation.engine
- column = engine.columns.detect{ |col| col.name.to_s == attribute.name.to_s }
+ column = engine.connection.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
if column && column.array
attribute.eq(value)
else
@@ -32,7 +32,7 @@
describe 'Associated record array query' do
it 'correctly identifies the column on associations with different class names' do
- person = Person.create(:habtm_tag_ids => [Tag.create(categories: ['wicked']).id])
+ person = Person.create(:habtm_tag_ids => [Tag.create(categories: ['wicked', 'awesome']).id])
wicked_people = Person.wicked_people
wicked_people.must_include(person)
end
View
@@ -18,7 +18,7 @@ class Person < ActiveRecord::Base
def self.wicked_people
includes(:habtm_tags)
- .where(:habtm_tags => {:categories => ['wicked','awesome']})
+ .where(:tags => {:categories => ['wicked','awesome']})
end
end

0 comments on commit add4d40

Please sign in to comment.