rdo 0.1.7 → 0.1.8
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.
- data/README.md +10 -0
- data/ext/rdo/rdo.c +7 -0
- data/lib/rdo/version.rb +1 -1
- data/spec/rdo/driver_spec.rb +10 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -277,6 +277,16 @@ This method returns nil if there are no rows, so if you need to distinguish
|
|
277
277
|
between NULL and no rows, you will need to check the result contents the
|
278
278
|
longer way around.
|
279
279
|
|
280
|
+
### Disambiguating bind markers from operators
|
281
|
+
|
282
|
+
Some drivers use '?' for operators. In order to avoid ambiguity, escape such
|
283
|
+
occurrences with a backslash. You **do not** need to escape inside of strings
|
284
|
+
and comments (i.e. wherever a bind marker could not naturally occur).
|
285
|
+
|
286
|
+
``` ruby
|
287
|
+
conn.execute(%q{SELECT 'a=>42,b=>7'::hstore \? ?}, "a")
|
288
|
+
```
|
289
|
+
|
280
290
|
### Debugging
|
281
291
|
|
282
292
|
A Logger instance (with an interface like that in Ruby stdlib) may be passed
|
data/ext/rdo/rdo.c
CHANGED
@@ -95,6 +95,13 @@ static VALUE rdo_driver_interpolate(VALUE self, VALUE stmt, VALUE params) {
|
|
95
95
|
// this loop is intentionally kept procedural (for performance)
|
96
96
|
for (; *s; ++s, ++b) {
|
97
97
|
switch (*s) {
|
98
|
+
case '\\':
|
99
|
+
if (!insquote && !indquote && !inmlcmt && !inslcmt && *(s + 1) == '?')
|
100
|
+
++s;
|
101
|
+
|
102
|
+
*b = *s;
|
103
|
+
break;
|
104
|
+
|
98
105
|
case '?':
|
99
106
|
if (insquote || indquote || inmlcmt || inslcmt) {
|
100
107
|
*b = *s;
|
data/lib/rdo/version.rb
CHANGED
data/spec/rdo/driver_spec.rb
CHANGED
@@ -84,6 +84,16 @@ describe RDO::Driver do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
context "with escaped marks" do
|
88
|
+
it "does not treat them as bind markers" do
|
89
|
+
driver.send(
|
90
|
+
:interpolate,
|
91
|
+
%q{SELECT 'a=>42,b=>7'::hstore \? ?},
|
92
|
+
["a"]
|
93
|
+
).should == "SELECT 'a=>42,b=>7'::hstore ? 'a'"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
87
97
|
context "with marks placed inside single quotes" do
|
88
98
|
it "ignores the quoted marks" do
|
89
99
|
driver.send(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|