mongery 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21bfa4edb20f8deed0f6cdf50a0480c5f08ada06
4
- data.tar.gz: 0e2446b75dec4e650f4712d6e9d1b05d9ca90bef
3
+ metadata.gz: 9aba484357e3a8ce7540342ebffe714395965f9e
4
+ data.tar.gz: af67b49c495afd48ed3fa88484b4b8910789d313
5
5
  SHA512:
6
- metadata.gz: fa8ab72c6b24d24ddd4ffacbe910a171cce25b0d2e11952120da64aef515bdae3b4f22b56de724f25ca919db0d1a999cb1ad06c42720ad302dc54fe67f5a1f72
7
- data.tar.gz: 494bcbeb04417a58914357b0dd8d6c9572d497eb082064edc75d12c74ef2fefae2d930eb7f3fb2916d0bb80c755c01a6f6016763b75bfa236d9596102423eb09
6
+ metadata.gz: 59a7ca1ac35849be2d4fd0ca2a980b0178c2a0f1f94bc5c9df5a0674f979dc465ecc39df058e04047377cf1d99d3ea9dc00b10bcf403fc39debf88bf2f9d3f24
7
+ data.tar.gz: 5f770ea95067208df3072d4b4b87dbe3bb72d4e78afea96b961f9c1a885e7422272f764622cacb16160f67e0f915ddba9a7db9bd1c20c28832419a3cf46cf94a
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.3 (2014/10/22)
2
+ - Fix a quotation bug
3
+
@@ -1,3 +1,3 @@
1
1
  module Mongery
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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 += "#{sep}'#{part}'"
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.2
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