mongery 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f07b3b2676098909d2b127f75970b95b4e4be027
4
- data.tar.gz: 9d5c86b70c843e233ebeb5d101c44e6f9ddef6ae
3
+ metadata.gz: 03d8acfca1ec4e920360fd762c038d5418f2cfaf
4
+ data.tar.gz: 66f7ec10c8e575b4bbdfbed72a35405c2fb40a4c
5
5
  SHA512:
6
- metadata.gz: 0442d0f7cf0f20fbf742fb5ece86d0bbed8f68642141742bcf2ef071c5bc78880d3bdef67e80a3f9b3eda7986695cdff66abe3baa308387746fb2cbb12f7bc35
7
- data.tar.gz: 258eb17e770f85b4ae08e1700429b77c9a6867dfd3137b002eba77caaeb774e6815bce2b3cfdde6307403f960c6dd70cdf7db03dbf912143b7e6029c07f2e88c
6
+ metadata.gz: 16ccca0d85eed4fe6c7f2cbdf391b26485196a9051d04be639f9a6b3dbb175e701d724c8edff4a0c972649ad5dad84cd702901a10991bee175aa6c29ed350c26
7
+ data.tar.gz: aa49ffa0ba15edc1a5a2efc4fc108c49845155ae7f033797e57e8ca4091da951f4062c4a7516e5582f6c20f8cf49754d2a8549781dc55c96f2fb511007e2d481
@@ -1,3 +1,6 @@
1
+ ## 1.0.1 (2014/12/22)
2
+ - Force string comparison on non-typed property
3
+
1
4
  ## 1.0.0 (2014/12/9)
2
5
  - This is a MAJOR update and is incompatible to the previous version
3
6
  - All JSON fields are now represented with JSON path (`data#>>{path}`)
@@ -263,17 +263,18 @@ module Mongery
263
263
  end
264
264
 
265
265
  def compare_schema(col, val, type, op)
266
- wrap_schema(col, type).send(op, val)
267
- end
268
-
269
- def wrap_schema(col, type)
270
266
  case type
271
267
  when "string"
272
- Arel.sql("(#{col})")
268
+ Arel.sql("(#{col})").send(op, val)
273
269
  when "number", "integer"
274
- Arel.sql("(#{col})::numeric")
270
+ Arel.sql("(#{col})::numeric").send(op, val)
275
271
  else
276
- col
272
+ case val
273
+ when Numeric
274
+ Arel.sql("(#{col})").send(op, val.to_s)
275
+ else
276
+ Arel.sql("(#{col})").send(op, val)
277
+ end
277
278
  end
278
279
  end
279
280
 
@@ -1,3 +1,3 @@
1
1
  module Mongery
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -16,7 +16,13 @@ describe Mongery::Builder do
16
16
  [ { tag: {"$in" => [ "food", "recipe" ]} },
17
17
  /WHERE \(data#>>'{tag}' ILIKE '%"food"%' OR data#>>'{tag}' ILIKE '%"recipe"%'\)$/ ],
18
18
  [ { active: true },
19
- /WHERE data#>>'{active}' = 'true'$/ ],
19
+ /WHERE \(data#>>'{active}'\) = 'true'$/ ],
20
+ [ { height: 2.1 },
21
+ /WHERE \(data#>>'{height}'\) = '2\.1'$/ ],
22
+ [ { height: { '$in' => ['6.1', '6.2'] } },
23
+ /WHERE \(data#>>'{height}'\) IN \('6\.1', '6\.2'\)$/ ],
24
+ [ { height: nil },
25
+ /WHERE \(data#>>'{height}'\) IS NULL$/ ],
20
26
  ]
21
27
 
22
28
  schema = JsonSchema.parse!(JSON.parse(<<-EOF))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuhiko Miyagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arel