mongo-parser-rb 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,7 +63,7 @@ module MongoParserRB
63
63
  when *Expression.equality_operators
64
64
  evaluate_equality(document)
65
65
  end
66
- rescue NoMethodError
66
+ rescue NoMethodError, TypeError
67
67
  false
68
68
  end
69
69
 
@@ -93,7 +93,11 @@ module MongoParserRB
93
93
  when :$ne
94
94
  value_for_field != @arguments
95
95
  when :$nin
96
- (value_for_field & @arguments).length.zero?
96
+ if value_for_field.kind_of?(Array)
97
+ (value_for_field & @arguments).length.zero?
98
+ else
99
+ !@arguments.include?(value_for_field)
100
+ end
97
101
  end
98
102
  end
99
103
 
@@ -117,7 +121,11 @@ module MongoParserRB
117
121
  when :$lte
118
122
  value_for_field <= @arguments
119
123
  when :$in
120
- (value_for_field & @arguments).length > 0
124
+ if value_for_field.kind_of?(Array)
125
+ (value_for_field & @arguments).length > 0
126
+ else
127
+ @arguments.include?(value_for_field)
128
+ end
121
129
  end
122
130
  end
123
131
 
@@ -1,3 +1,3 @@
1
1
  module MongoParserRB
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -122,6 +122,13 @@ class QueryTest < MiniTest::Unit::TestCase
122
122
  refute query.matches_document?(:array_key => [1,4,5])
123
123
  end
124
124
 
125
+ def test_integer_in
126
+ query = MongoParserRB::Query.parse(:integer_key => {:$in => [1,2]})
127
+ assert query.matches_document?(:integer_key => 1)
128
+ assert query.matches_document?(:integer_key => 2)
129
+ refute query.matches_document?(:integer_key => 3)
130
+ end
131
+
125
132
  def test_eq_nil
126
133
  query = MongoParserRB::Query.parse(:string_key => nil)
127
134
  assert query.matches_document?(:string_key => nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo-parser-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: