lib/adapters/parse_adapter.rb in dm-parse-0.3.14 vs lib/adapters/parse_adapter.rb in dm-parse-0.3.15
- old
+ new
@@ -205,10 +205,11 @@
result["$or"] = result["$or"] + condition.map do |c|
r = {}
translate c, r
r
end
+ when ["0 = 1"] # workaround for cancan
else
raise NotImplementedError
end
end
@@ -270,12 +271,13 @@
def combine(comparisons)
groups = comparisons.group_by { |comparison| comparison.is_a? Eql }
equals = groups[true]
others = groups[false]
- if equals.present? && others.present?
- raise "Parse Query: cannot combine Eql with others"
- elsif equals.present?
+ # It's such a pity that js query cannot combine equal comparison
+ # with other comparisons, but DataMapper will construct query
+ # in that way.
+ if equals.present?
raise "can only use one EqualToComparison for a field" unless equals.size == 1
equals.first.as_json
elsif others.present?
others.inject({}) do |result, comparison|
result.merge! comparison.as_json