mao 0.0.5 → 0.0.6
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/lib/mao.rb +5 -1
- data/lib/mao/version.rb +1 -1
- data/spec/mao_spec.rb +8 -0
- metadata +1 -1
data/lib/mao.rb
CHANGED
@@ -40,7 +40,11 @@ module Mao
|
|
40
40
|
def self.escape_literal(value)
|
41
41
|
case value
|
42
42
|
when String
|
43
|
-
@conn.escape_literal
|
43
|
+
if @conn.respond_to?(:escape_literal)
|
44
|
+
@conn.escape_literal(value)
|
45
|
+
else
|
46
|
+
"'#{@conn.escape_string(value)}'"
|
47
|
+
end
|
44
48
|
when NilClass
|
45
49
|
"null"
|
46
50
|
when TrueClass
|
data/lib/mao/version.rb
CHANGED
data/spec/mao_spec.rb
CHANGED
@@ -52,6 +52,14 @@ describe Mao do
|
|
52
52
|
it { Mao.escape_literal(nil).should eq "null" }
|
53
53
|
end
|
54
54
|
|
55
|
+
describe "verify escape_literal-less PG::Connection" do
|
56
|
+
before { PG::Connection.any_instance.should_receive(:respond_to?).
|
57
|
+
with(:escape_literal).and_return(false) }
|
58
|
+
before { PG::Connection.any_instance.should_receive(:escape_string).
|
59
|
+
with("xyz'hah").and_return("xyz''hah") }
|
60
|
+
it { Mao.escape_literal("xyz'hah").should eq %q{'xyz''hah'} }
|
61
|
+
end
|
62
|
+
|
55
63
|
describe "actual values" do
|
56
64
|
it { Mao.escape_literal("table").should eq %q{'table'} }
|
57
65
|
it { Mao.escape_literal(42).should eq %q{42} }
|