pg-hstore 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pg_hstore.rb +10 -6
  2. metadata +2 -2
@@ -33,16 +33,16 @@ module PgHstore
33
33
  # represent nil as NULL without quotes
34
34
  v = "NULL"
35
35
  else
36
- v = v.to_s
36
+ v = double_quote_escape v
37
37
  unless for_parameter
38
- v = to_s_escaped v
38
+ v = single_quote_escape v
39
39
  end
40
40
  # otherwise, write a double-quoted string with backslash escapes for quotes
41
41
  v = DOUBLE_QUOTE + v + DOUBLE_QUOTE
42
42
  end
43
- k = k.to_s
43
+ k = double_quote_escape k
44
44
  unless for_parameter
45
- k = to_s_escaped k
45
+ k = single_quote_escape k
46
46
  end
47
47
  k = DOUBLE_QUOTE + k + DOUBLE_QUOTE
48
48
 
@@ -83,8 +83,12 @@ module PgHstore
83
83
  scanner.skip(/,\s*/)
84
84
  end
85
85
 
86
- def to_s_escaped(str)
87
- str.gsub(/\\(?!")/) {'\\\\'}.gsub(DOUBLE_QUOTE, '\"').gsub(SINGLE_QUOTE, "''")
86
+ def double_quote_escape(str)
87
+ str.to_s.gsub DOUBLE_QUOTE, '\"'
88
+ end
89
+
90
+ def single_quote_escape(str)
91
+ str.to_s.gsub(/\\(?!")/) {'\\\\'}.gsub(SINGLE_QUOTE, "''")
88
92
  end
89
93
 
90
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg-hstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-20 00:00:00.000000000 Z
13
+ date: 2013-01-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec