Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:sam/dm-core
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Aug 30, 2008
2 parents 55f47fa + f287a1c commit ded4769
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/dm-core/adapters/data_objects_adapter.rb
Expand Up @@ -327,15 +327,6 @@ def condition_statement(query, operator, left_condition, right_condition)
"(#{read_statement(condition)})"
elsif condition.kind_of?(Array) && condition.all? { |p| p.kind_of?(Property) }
property_values = condition.map { |p| property_to_column_name(query.repository, p, qualify) }
# An IN() clause with an empty set is the same as a false condition
# IN() with an empty set is not supported on all RDMS, but this is.
if property_values.empty?
if [:eql, :in, :not].include? operator
return operator == :not ? "1=1" : "0=1"
else
raise "Invalid query operator #{operator.inspect} for #{property_values.inspect}"
end
end
"(#{property_values * ', '})"
else
'?'
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/query_spec.rb
Expand Up @@ -258,12 +258,25 @@ class << operator

find = QuerySpec::SailBoat.all(:id.not => [1,2])
find.should have(1).entries
end
end

it "should find by conditions passed in as an empty array" do
repository(ADAPTER) do
find = QuerySpec::SailBoat.all(:id => [])
find.should have(0).entries

find = QuerySpec::SailBoat.all(:id.not => [])
find.should have(3).entries

find = QuerySpec::SailBoat.all(:id => [], :name => "A")
find.should have(0).entries

find = QuerySpec::SailBoat.all(:id.not => [], :name => "A")
find.should have(1).entries

find = QuerySpec::SailBoat.all(:id.not => [], :name => ["A", "B"])
find.should have(2).entries
end
end

Expand Down

0 comments on commit ded4769

Please sign in to comment.