mongery 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/mongery/version.rb +1 -1
- data/lib/mongery.rb +8 -1
- data/spec/mongery/builder_spec.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aba484357e3a8ce7540342ebffe714395965f9e
|
4
|
+
data.tar.gz: af67b49c495afd48ed3fa88484b4b8910789d313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a7ca1ac35849be2d4fd0ca2a980b0178c2a0f1f94bc5c9df5a0674f979dc465ecc39df058e04047377cf1d99d3ea9dc00b10bcf403fc39debf88bf2f9d3f24
|
7
|
+
data.tar.gz: 5f770ea95067208df3072d4b4b87dbe3bb72d4e78afea96b961f9c1a885e7422272f764622cacb16160f67e0f915ddba9a7db9bd1c20c28832419a3cf46cf94a
|
data/CHANGELOG.md
ADDED
data/lib/mongery/version.rb
CHANGED
data/lib/mongery.rb
CHANGED
@@ -65,6 +65,8 @@ module Mongery
|
|
65
65
|
self
|
66
66
|
end
|
67
67
|
|
68
|
+
private
|
69
|
+
|
68
70
|
def translate(query)
|
69
71
|
chain(:and, query.map { |col, value| translate_cv(col, value) })
|
70
72
|
end
|
@@ -158,11 +160,16 @@ module Mongery
|
|
158
160
|
parts = col.to_s.split('.')
|
159
161
|
parts.each_with_index do |part, index|
|
160
162
|
sep = index == parts.size - 1 ? "->>" : "->"
|
161
|
-
path +=
|
163
|
+
path += sep + quote(part)
|
162
164
|
end
|
163
165
|
Arel.sql(path)
|
164
166
|
end
|
165
167
|
|
168
|
+
def quote(str)
|
169
|
+
# FIXME there should be a better way to do this
|
170
|
+
table.engine.connection.quote(str)
|
171
|
+
end
|
172
|
+
|
166
173
|
def chain(op, conditions)
|
167
174
|
result = nil
|
168
175
|
conditions.each do |cond|
|
@@ -24,6 +24,8 @@ describe Mongery::Builder do
|
|
24
24
|
/WHERE data->>'name' = ''$/ ],
|
25
25
|
[ { name: "foo", other: "bar" }, { },
|
26
26
|
/WHERE data->>'name' = 'foo' AND data->>'other' = 'bar'/ ],
|
27
|
+
[ { "x'y" => "foo" }, { },
|
28
|
+
/WHERE data->>'x''y' = 'foo'/ ],
|
27
29
|
[ { weight: 66 }, { },
|
28
30
|
/WHERE data->>'weight' = '66'$/ ],
|
29
31
|
[ { weight: { "$gt" => 66 } }, { },
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuhiko Miyagawa
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
|
+
- CHANGELOG.md
|
105
106
|
- Gemfile
|
106
107
|
- LICENSE.txt
|
107
108
|
- README.md
|