pg 0.18.1 → 0.18.2
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +169 -2
- data/History.rdoc +16 -0
- data/README.rdoc +1 -1
- data/ext/extconf.rb +4 -1
- data/ext/pg.c +3 -3
- data/ext/pg.h +10 -0
- data/ext/pg_connection.c +12 -40
- data/ext/pg_result.c +4 -4
- data/ext/pg_text_decoder.c +7 -10
- data/ext/pg_text_encoder.c +37 -40
- data/ext/pg_type_map_by_mri_type.c +2 -2
- data/ext/pg_type_map_in_ruby.c +4 -7
- data/ext/util.c +2 -2
- data/ext/util.h +1 -1
- data/lib/pg.rb +2 -2
- data/lib/pg/connection.rb +37 -27
- data/lib/pg/text_decoder.rb +2 -2
- data/spec/pg/connection_spec.rb +82 -6
- data/spec/pg/type_spec.rb +53 -30
- metadata +32 -32
- metadata.gz.sig +0 -0
data/spec/pg/type_spec.rb
CHANGED
@@ -15,6 +15,8 @@ describe "PG::Type derivations" do
|
|
15
15
|
let!(:textdec_string) { PG::TextDecoder::String.new }
|
16
16
|
let!(:textenc_timestamp) { PG::TextEncoder::TimestampWithoutTimeZone.new }
|
17
17
|
let!(:textdec_timestamp) { PG::TextDecoder::TimestampWithoutTimeZone.new }
|
18
|
+
let!(:textenc_timestamptz) { PG::TextEncoder::TimestampWithTimeZone.new }
|
19
|
+
let!(:textdec_timestamptz) { PG::TextDecoder::TimestampWithTimeZone.new }
|
18
20
|
let!(:textenc_bytea) { PG::TextEncoder::Bytea.new }
|
19
21
|
let!(:textdec_bytea) { PG::TextDecoder::Bytea.new }
|
20
22
|
let!(:binaryenc_int2) { PG::BinaryEncoder::Int2.new }
|
@@ -85,6 +87,48 @@ describe "PG::Type derivations" do
|
|
85
87
|
expect( textdec_bytea.decode("\\377\\000") ).to eq( "\xff\0".b )
|
86
88
|
end
|
87
89
|
|
90
|
+
context 'timestamps' do
|
91
|
+
it 'decodes timestamps without timezone' do
|
92
|
+
expect( textdec_timestamp.decode('2016-01-02 23:23:59.123456') ).
|
93
|
+
to be_within(0.000001).of( Time.new(2016,01,02, 23, 23, 59.123456) )
|
94
|
+
end
|
95
|
+
it 'decodes timestamps with hour timezone' do
|
96
|
+
expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-04') ).
|
97
|
+
to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:00") )
|
98
|
+
expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511+10') ).
|
99
|
+
to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "+10:00") )
|
100
|
+
end
|
101
|
+
it 'decodes timestamps with hour:minute timezone' do
|
102
|
+
expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-04:15') ).
|
103
|
+
to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:15") )
|
104
|
+
expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-0430') ).
|
105
|
+
to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:30") )
|
106
|
+
expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511+10:45') ).
|
107
|
+
to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "+10:45") )
|
108
|
+
end
|
109
|
+
it 'decodes timestamps with hour:minute:sec timezone' do
|
110
|
+
# SET TIME ZONE 'Europe/Dublin'; -- Was UTC−00:25:21 until 1916
|
111
|
+
# SELECT '1900-01-01'::timestamptz;
|
112
|
+
# -- "1900-01-01 00:00:00-00:25:21"
|
113
|
+
expect( textdec_timestamptz.decode('1916-01-01 00:00:00-00:25:21') ).
|
114
|
+
to be_within(0.000001).of( Time.new(1916, 1, 1, 0, 0, 0, "-00:25:21") )
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'identifier quotation' do
|
119
|
+
it 'should build an array out of an quoted identifier string' do
|
120
|
+
quoted_type = PG::TextDecoder::Identifier.new
|
121
|
+
expect( quoted_type.decode(%["A.".".B"]) ).to eq( ["A.", ".B"] )
|
122
|
+
expect( quoted_type.decode(%["'A"".""B'"]) ).to eq( ['\'A"."B\''] )
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should split unquoted identifier string' do
|
126
|
+
quoted_type = PG::TextDecoder::Identifier.new
|
127
|
+
expect( quoted_type.decode(%[a.b]) ).to eq( ['a','b'] )
|
128
|
+
expect( quoted_type.decode(%[a]) ).to eq( ['a'] )
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
88
132
|
it "should raise when decode method is called with wrong args" do
|
89
133
|
expect{ textdec_int.decode() }.to raise_error(ArgumentError)
|
90
134
|
expect{ textdec_int.decode("123", 2, 3, 4) }.to raise_error(ArgumentError)
|
@@ -156,6 +200,15 @@ describe "PG::Type derivations" do
|
|
156
200
|
expect( textenc_bytea.encode("\x00\x01\x02\x03\xef".b) ).to eq( "\\x00010203ef" )
|
157
201
|
end
|
158
202
|
|
203
|
+
context 'identifier quotation' do
|
204
|
+
it 'should quote and escape identifier' do
|
205
|
+
quoted_type = PG::TextEncoder::Identifier.new
|
206
|
+
expect( quoted_type.encode(['schema','table','col']) ).to eq( %["schema"."table"."col"] )
|
207
|
+
expect( quoted_type.encode(['A.','.B']) ).to eq( %["A.".".B"] )
|
208
|
+
expect( quoted_type.encode(%['A"."B']) ).to eq( %["'A"".""B'"] )
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
159
212
|
it "should encode with ruby encoder" do
|
160
213
|
expect( intenc_incrementer.encode(3) ).to eq( "4 " )
|
161
214
|
end
|
@@ -347,20 +400,6 @@ describe "PG::Type derivations" do
|
|
347
400
|
array_type = PG::TextDecoder::Array.new elements_type: nil
|
348
401
|
expect( array_type.decode(%[{3,4}]) ).to eq( ['3','4'] )
|
349
402
|
end
|
350
|
-
|
351
|
-
context 'identifier quotation' do
|
352
|
-
it 'should build an array out of an quoted identifier string' do
|
353
|
-
quoted_type = PG::TextDecoder::Identifier.new elements_type: textdec_string
|
354
|
-
expect( quoted_type.decode(%["A.".".B"]) ).to eq( ["A.", ".B"] )
|
355
|
-
expect( quoted_type.decode(%["'A"".""B'"]) ).to eq( ['\'A"."B\''] )
|
356
|
-
end
|
357
|
-
|
358
|
-
it 'should split unquoted identifier string' do
|
359
|
-
quoted_type = PG::TextDecoder::Identifier.new elements_type: textdec_string
|
360
|
-
expect( quoted_type.decode(%[a.b]) ).to eq( ['a','b'] )
|
361
|
-
expect( quoted_type.decode(%[a]) ).to eq( ['a'] )
|
362
|
-
end
|
363
|
-
end
|
364
403
|
end
|
365
404
|
|
366
405
|
describe '#encode' do
|
@@ -422,22 +461,6 @@ describe "PG::Type derivations" do
|
|
422
461
|
expect( textenc_float_array.encode(1234) ).to eq( "1234" )
|
423
462
|
end
|
424
463
|
|
425
|
-
context 'identifier quotation' do
|
426
|
-
it 'should quote and escape identifier' do
|
427
|
-
quoted_type = PG::TextEncoder::Identifier.new elements_type: textenc_string
|
428
|
-
expect( quoted_type.encode(['schema','table','col']) ).to eq( %["schema"."table"."col"] )
|
429
|
-
expect( quoted_type.encode(['A.','.B']) ).to eq( %["A.".".B"] )
|
430
|
-
expect( quoted_type.encode(%['A"."B']) ).to eq( %["'A"".""B'"] )
|
431
|
-
end
|
432
|
-
|
433
|
-
it 'shouldn\'t quote or escape identifier if requested to not do' do
|
434
|
-
quoted_type = PG::TextEncoder::Identifier.new elements_type: textenc_string,
|
435
|
-
needs_quotation: false
|
436
|
-
expect( quoted_type.encode(['a','b']) ).to eq( %[a.b] )
|
437
|
-
expect( quoted_type.encode(%[a.b]) ).to eq( %[a.b] )
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
464
|
context 'literal quotation' do
|
442
465
|
it 'should quote and escape literals' do
|
443
466
|
quoted_type = PG::TextEncoder::QuotedLiteral.new elements_type: textenc_string_array
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -13,7 +13,7 @@ cert_chain:
|
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
14
|
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
|
15
15
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
16
|
-
|
16
|
+
HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
|
17
17
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
18
18
|
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
|
19
19
|
+Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
|
@@ -24,125 +24,125 @@ cert_chain:
|
|
24
24
|
AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSZ0hCV
|
25
25
|
qoHr122fGKelqffzEQBhszAcBgNVHREEFTATgRFnZWRARmFlcmllTVVELm9yZzAc
|
26
26
|
BgNVHRIEFTATgRFnZWRARmFlcmllTVVELm9yZzANBgkqhkiG9w0BAQUFAAOCAQEA
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
lUKo3NXePpuvN3QGsOLJ6QhNd4+Q9Rz75GipuMrCl296V8QFkd2gg9EG44Pqtk+9
|
28
|
+
Zac8TkKc9bCSR0snakp+cCPplVvZF0/gMzkSTUJkDBHlNV16z73CyWpbQQa+iLJ4
|
29
|
+
uisI6gF2ZXK919MYLn2bFJfb7OsCvVfyTPqq8afPY+rq9vlf9ZPwU49AlD8bPRic
|
30
|
+
0LX0gO5ykvETIOv+WgGcqp96ceNi9XVuJMh20uWuw6pmv/Ub2RqAf82jQSbpz09G
|
31
|
+
G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
|
32
|
+
xn3DzOkDE6NYbk8gC9rTsA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-
|
34
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hoe-mercurial
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.4'
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.4'
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: hoe-deveiate
|
52
52
|
requirement: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0.6'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - ~>
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0.6'
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: hoe-highline
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - ~>
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0.2'
|
71
71
|
type: :development
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - ~>
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0.2'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: rdoc
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - ~>
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '4.0'
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - ~>
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '4.0'
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rake-compiler
|
94
94
|
requirement: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - ~>
|
96
|
+
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0.9'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
101
|
version_requirements: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - ~>
|
103
|
+
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0.9'
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
107
|
name: hoe
|
108
108
|
requirement: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - ~>
|
110
|
+
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '3.12'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
115
|
version_requirements: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - ~>
|
117
|
+
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '3.12'
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
121
|
name: hoe-bundler
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - ~>
|
124
|
+
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '1.0'
|
127
127
|
type: :development
|
128
128
|
prerelease: false
|
129
129
|
version_requirements: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - ~>
|
131
|
+
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '1.0'
|
134
134
|
- !ruby/object:Gem::Dependency
|
135
135
|
name: rspec
|
136
136
|
requirement: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - ~>
|
138
|
+
- - "~>"
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '3.0'
|
141
141
|
type: :development
|
142
142
|
prerelease: false
|
143
143
|
version_requirements: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- - ~>
|
145
|
+
- - "~>"
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '3.0'
|
148
148
|
description: |-
|
@@ -202,7 +202,7 @@ extra_rdoc_files:
|
|
202
202
|
- ext/pg_type_map_in_ruby.c
|
203
203
|
- ext/util.c
|
204
204
|
files:
|
205
|
-
- .gemtest
|
205
|
+
- ".gemtest"
|
206
206
|
- BSDL
|
207
207
|
- ChangeLog
|
208
208
|
- Contributors.rdoc
|
@@ -295,27 +295,27 @@ licenses:
|
|
295
295
|
metadata: {}
|
296
296
|
post_install_message:
|
297
297
|
rdoc_options:
|
298
|
-
- -f
|
298
|
+
- "-f"
|
299
299
|
- fivefish
|
300
|
-
- -t
|
300
|
+
- "-t"
|
301
301
|
- 'pg: The Ruby Interface to PostgreSQL'
|
302
|
-
- -m
|
302
|
+
- "-m"
|
303
303
|
- README.rdoc
|
304
304
|
require_paths:
|
305
305
|
- lib
|
306
306
|
required_ruby_version: !ruby/object:Gem::Requirement
|
307
307
|
requirements:
|
308
|
-
- -
|
308
|
+
- - ">="
|
309
309
|
- !ruby/object:Gem::Version
|
310
310
|
version: 1.9.3
|
311
311
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
312
|
requirements:
|
313
|
-
- -
|
313
|
+
- - ">="
|
314
314
|
- !ruby/object:Gem::Version
|
315
315
|
version: '0'
|
316
316
|
requirements: []
|
317
317
|
rubyforge_project:
|
318
|
-
rubygems_version: 2.4.
|
318
|
+
rubygems_version: 2.4.6
|
319
319
|
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
|
metadata.gz.sig
CHANGED
Binary file
|