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 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(value)
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
@@ -1,5 +1,5 @@
1
1
  module Mao
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
4
4
 
5
5
  # vim: set sw=2 cc=80 et:
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} }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: