Permalink
Browse files

Got the adapter conforming to the shared adapter specs

  • Loading branch information...
1 parent 8137a80 commit 47c193b2a92c9dce8072a165a59ed7fe45537564 @airhorns committed Apr 16, 2011
Showing with 17 additions and 8 deletions.
  1. +17 −8 lib/dm-redis-adapter/adapter.rb
@@ -53,7 +53,6 @@ def read(query)
record
end
query.filter_records(fetched)
- fetched
end
##
@@ -195,7 +194,6 @@ def keys_for_conditions(query, condition = nil)
when AbstractOperation then keys_for_operation(query, condition)
when AbstractComparison then keys_for_comparison(query, condition)
else
- debugger
raise NotImplementedError
end
end
@@ -212,7 +210,6 @@ def keys_for_operation(query, operation)
end
when OrOperation then
else
- debugger
raise NotImplementedError
end
end
@@ -222,11 +219,21 @@ def keys_for_comparison(query, comparison)
when EqualToComparison then
_get_keys_for_comparison(query, comparison, comparison.value)
when InclusionComparison then
- comparison.value.map do |value|
- keys = _get_keys_for_comparison(query, comparison, value)
- return nil if keys.nil?
- keys
- end.flatten
+ if comparison.value.count == 0
+ if comparison.negated?
+ return @redis.smembers(key_set_for(comparison.subject.model))
+ else
+ return []
+ end
+ else
+ comparison.value.map do |value|
+ keys = _get_keys_for_comparison(query, comparison, value)
+ return nil if keys.nil?
+ keys
+ end.flatten
+ end
+ when LikeComparison, RegexpComparison, GreaterThanComparison, GreaterThanOrEqualToComparison, LessThanComparison, LessThanOrEqualToComparison then
+ return nil
else
raise NotImplementedError
end
@@ -266,6 +273,8 @@ def find_property_index_matches(query, comparison, value)
if query.model.key.include?(comparison.subject)
if @redis.sismember(key_set_for(query.model), value)
affirmative = [value]
+ else
+ affirmative = []
end
unless comparison.negated?

0 comments on commit 47c193b

Please sign in to comment.