mongo_ql 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: a2694eccc5339f8c810e6988339bf6faa9325d86518d810eb1f1d43645022e26
4
- data.tar.gz: 605cf542eeae93fd97ae4135d5c62dd8b07abf8a6c593c2f415b1676071aa185
3
+ metadata.gz: 9fb2a34c81b04e11611b3c4ae164bdd49ccb285e4d04b9d75b5a67f4c2495175
4
+ data.tar.gz: ba2997c9c6ae7e58453cf0b86b8b91e30d7a16fd1b7a1bcb4b6b449d3dec0013
5
5
  SHA512:
6
- metadata.gz: a7032e9dc8bce476e20345e0c3702f9563e778612914db1080b4c85022d2de8cc610a26c8cac4a2b4e4fc92dce1bade62498d25b36e9cf60bcab55e00d24be92
7
- data.tar.gz: eba833dc7d70fee8958ea30812f01181ce943b9cce00a9d5b7663458ce5547dd874bc3aea907fa19719a72fabc08036899a2c559f9b6718a0490b28bd4612fbb
6
+ metadata.gz: 00c8fd708900c9a9c2b17da095b57a9f764153095a0e968a271107f251a8d0747f24c3c26c90a14272cecb349940ea162f03c92e429f8ce50963a3012fa9eb85
7
+ data.tar.gz: 3e9fcfad599743a25bb84f2b85b41caf4122a1067188be0e43436e238ea37a8f9293860e09f7e10321707c80beb84338c5c976db9bafcd75d94d63c0f32375b2
@@ -5,7 +5,7 @@ module MongoQL
5
5
  SUPPORTED_TYPES = [
6
6
  String, Integer, Float,
7
7
  Array, Hash, TrueClass,
8
- FalseClass, Date, Symbol,
8
+ FalseClass, Date, DateTime, Symbol,
9
9
  MongoQL::Expression::ValueNode
10
10
  ].freeze
11
11
 
@@ -17,7 +17,14 @@ module MongoQL
17
17
  end
18
18
 
19
19
  def to_ast
20
- value.is_a?(MongoQL::Expression::ValueNode) ? value.to_ast : value
20
+ case value
21
+ when Date, DateTime
22
+ Expression::ValueNode.new(value.iso8601).to_date.to_ast
23
+ when MongoQL::Expression::ValueNode
24
+ value.to_ast
25
+ else
26
+ value
27
+ end
21
28
  end
22
29
 
23
30
  def self.valid?(value)
@@ -25,7 +32,7 @@ module MongoQL
25
32
  end
26
33
 
27
34
  def self.valid!(value)
28
- unless valid?(value)
35
+ unless value.nil? || valid?(value)
29
36
  raise InvalidValueExpression, "#{value} must be in type #{SUPPORTED_TYPES.map(&:name).join(",")}"
30
37
  end
31
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MongoQL
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
data/lib/mongo_ql.rb CHANGED
@@ -32,7 +32,6 @@ module MongoQL
32
32
 
33
33
  ctx.instance_exec(*variables, &block)
34
34
  ctx
35
-
36
35
  ensure
37
36
  # Restore local variables
38
37
  variable_names.each do |name|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_ql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xizheng Ding
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-28 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake