pg 0.18.0.pre20141017160319-x86-mingw32 → 0.18.0.pre20141117110243-x86-mingw32

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.
@@ -87,6 +87,20 @@ describe PG::TypeMapByMriType do
87
87
  expect{ tm[123] = textenc_float }.to raise_error(TypeError)
88
88
  end
89
89
 
90
+ it "forwards query param conversions to the #default_type_map" do
91
+ tm1 = PG::TypeMapByColumn.new( [textenc_int, nil, nil] )
92
+
93
+ tm2 = PG::TypeMapByMriType.new
94
+ tm2['T_FIXNUM'] = PG::TextEncoder::Integer.new name: 'INT2', oid: 21
95
+ tm2.default_type_map = tm1
96
+
97
+ res = @conn.exec_params( "SELECT $1, $2, $3::TEXT", ['1', 2, 3], 0, tm2 )
98
+
99
+ expect( res.ftype(0) ).to eq( 23 ) # tm1
100
+ expect( res.ftype(1) ).to eq( 21 ) # tm2
101
+ expect( res.getvalue(0,2) ).to eq( "3" ) # TypeMapAllStrings
102
+ end
103
+
90
104
  #
91
105
  # Decoding Examples
92
106
  #
@@ -85,6 +85,27 @@ describe PG::TypeMapByOid do
85
85
  expect( tm2.coders ).to eq( [textdec_int, nil, textdec_float, pass_through_type] )
86
86
  end
87
87
 
88
+ it "forwards result value conversions to another TypeMapByOid as #default_type_map" do
89
+ # One run with implicit built TypeMapByColumn and another with online lookup
90
+ # for each type map.
91
+ [[0, 0], [0, 10], [10, 0], [10, 10]].each do |max_rows1, max_rows2|
92
+ tm1 = PG::TypeMapByOid.new
93
+ tm1.add_coder PG::TextDecoder::Integer.new name: 'INT2', oid: 21
94
+ tm1.max_rows_for_online_lookup = max_rows1
95
+
96
+ tm2 = PG::TypeMapByOid.new
97
+ tm2.add_coder PG::TextDecoder::Integer.new name: 'INT4', oid: 23
98
+ tm2.max_rows_for_online_lookup = max_rows2
99
+ tm2.default_type_map = tm1
100
+
101
+ res = @conn.exec( "SELECT '1'::INT4, '2'::INT2, '3'::INT8" ).map_types!( tm2 )
102
+
103
+ expect( res.getvalue(0,0) ).to eq( 1 ) # tm2
104
+ expect( res.getvalue(0,1) ).to eq( 2 ) # tm1
105
+ expect( res.getvalue(0,2) ).to eq( "3" ) # TypeMapAllStrings
106
+ end
107
+ end
108
+
88
109
  #
89
110
  # Decoding Examples text format
90
111
  #
@@ -15,6 +15,7 @@ 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_bytea) { PG::TextEncoder::Bytea.new }
18
19
  let!(:textdec_bytea) { PG::TextDecoder::Bytea.new }
19
20
  let!(:binaryenc_int2) { PG::BinaryEncoder::Int2.new }
20
21
  let!(:binaryenc_int4) { PG::BinaryEncoder::Int4.new }
@@ -92,8 +93,8 @@ describe "PG::Type derivations" do
92
93
  end
93
94
 
94
95
  it "should pass through nil values" do
95
- expect( textdec_string.encode( nil )).to be_nil
96
- expect( textdec_int.encode( nil )).to be_nil
96
+ expect( textdec_string.decode( nil )).to be_nil
97
+ expect( textdec_int.decode( nil )).to be_nil
97
98
  end
98
99
  end
99
100
 
@@ -155,6 +156,10 @@ describe "PG::Type derivations" do
155
156
  expect( textenc_float.encode(-Float::NAN) ).to eq( Float::NAN.to_s )
156
157
  end
157
158
 
159
+ it "encodes binary string to bytea" do
160
+ expect( textenc_bytea.encode("\x00\x01\x02\x03\xef".b) ).to eq( "\\x00010203ef" )
161
+ end
162
+
158
163
  it "should encode with ruby encoder" do
159
164
  expect( intenc_incrementer.encode(3) ).to eq( "4 " )
160
165
  end
@@ -192,6 +197,21 @@ describe "PG::Type derivations" do
192
197
  expect( t.format ).to eq( 0 )
193
198
  expect( t.oid ).to eq( 0 )
194
199
  expect( t.name ).to be_nil
200
+
201
+ t = PG::BinaryEncoder::Int4.new
202
+ expect( t.format ).to eq( 1 )
203
+ expect( t.oid ).to eq( 0 )
204
+ expect( t.name ).to be_nil
205
+
206
+ t = PG::TextDecoder::String.new
207
+ expect( t.format ).to eq( 0 )
208
+ expect( t.oid ).to eq( 0 )
209
+ expect( t.name ).to be_nil
210
+
211
+ t = PG::BinaryDecoder::String.new
212
+ expect( t.format ).to eq( 1 )
213
+ expect( t.oid ).to eq( 0 )
214
+ expect( t.name ).to be_nil
195
215
  end
196
216
  end
197
217
 
@@ -565,12 +585,12 @@ describe "PG::Type derivations" do
565
585
  end
566
586
  end
567
587
 
568
- context "with TypeMapByMriType" do
588
+ context "with TypeMapByClass" do
569
589
  let!(:tm) do
570
- tm = PG::TypeMapByMriType.new
571
- tm['T_FIXNUM'] = textenc_int
572
- tm['T_FLOAT'] = intenc_incrementer
573
- tm['T_ARRAY'] = PG::TextEncoder::Array.new elements_type: textenc_string
590
+ tm = PG::TypeMapByClass.new
591
+ tm[Integer] = textenc_int
592
+ tm[Float] = intenc_incrementer
593
+ tm[Array] = PG::TextEncoder::Array.new elements_type: textenc_string
574
594
  tm
575
595
  end
576
596
  let!(:encoder) do
@@ -12,6 +12,20 @@ describe PG do
12
12
  expect( PG.library_version ).to be >= 90100
13
13
  end
14
14
 
15
+ it "can select which of both security libraries to initialize" do
16
+ # This setting does nothing here, because there is already a connection
17
+ # to the server, at this point in time.
18
+ PG.init_openssl(false, true)
19
+ PG.init_openssl(1, 0)
20
+ end
21
+
22
+ it "can select whether security libraries to initialize" do
23
+ # This setting does nothing here, because there is already a connection
24
+ # to the server, at this point in time.
25
+ PG.init_ssl(false)
26
+ PG.init_ssl(1)
27
+ end
28
+
15
29
 
16
30
  it "knows whether or not the library is threadsafe" do
17
31
  expect( PG ).to be_threadsafe()
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.0.pre20141017160319
4
+ version: 0.18.0.pre20141117110243
5
5
  platform: x86-mingw32
6
6
  authors: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JXlwjPyjGbZY9gVfOwAwMibYOK/t/+57ZzW3d0L12OUwvo
27
+ on84NVvYtIr1/iskJFWFkMoIquAFCdi9p68stSPMQK2XcrJJuRot29fJtropsZBa
28
+ 2cpaNd/sRYdK4oep2usdKifA1lI0hIkPb3r5nLfwG2lAqBH7WZsUICHcTgR0VEbG
29
+ z9Ug5qQp9Uz73xC9YdGvGiuOX53LYobHAR4MWi2xxDlHI+ER8mRz0eY2FUuNu/Wj
30
+ GrqF74zpLl7/KFdHC8VmzwZS18hvDjxeLVuVI2gIGnBInqnlqv05g/l4/1pISh5j
31
+ dS4=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-10-21 00:00:00.000000000 Z
33
+ date: 2014-11-17 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: hoe-mercurial
@@ -193,6 +193,7 @@ extra_rdoc_files:
193
193
  - ext/pg_text_encoder.c
194
194
  - ext/pg_type_map.c
195
195
  - ext/pg_type_map_all_strings.c
196
+ - ext/pg_type_map_by_class.c
196
197
  - ext/pg_type_map_by_column.c
197
198
  - ext/pg_type_map_by_mri_type.c
198
199
  - ext/pg_type_map_by_oid.c
@@ -231,6 +232,7 @@ files:
231
232
  - ext/pg_text_encoder.c
232
233
  - ext/pg_type_map.c
233
234
  - ext/pg_type_map_all_strings.c
235
+ - ext/pg_type_map_by_class.c
234
236
  - ext/pg_type_map_by_column.c
235
237
  - ext/pg_type_map_by_mri_type.c
236
238
  - ext/pg_type_map_by_oid.c
@@ -277,6 +279,7 @@ files:
277
279
  - spec/pg/basic_type_mapping_spec.rb
278
280
  - spec/pg/connection_spec.rb
279
281
  - spec/pg/result_spec.rb
282
+ - spec/pg/type_map_by_class_spec.rb
280
283
  - spec/pg/type_map_by_column_spec.rb
281
284
  - spec/pg/type_map_by_mri_type_spec.rb
282
285
  - spec/pg/type_map_by_oid_spec.rb
@@ -311,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
314
  version: 1.3.1
312
315
  requirements: []
313
316
  rubyforge_project:
314
- rubygems_version: 2.3.0
317
+ rubygems_version: 2.2.2
315
318
  signing_key:
316
319
  specification_version: 4
317
320
  summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
metadata.gz.sig CHANGED
Binary file