pg 1.1.4 → 1.2.3
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 +0 -6595
 - data/History.rdoc +86 -0
 - data/Manifest.txt +3 -2
 - data/README-Windows.rdoc +4 -4
 - data/README.ja.rdoc +1 -2
 - data/README.rdoc +44 -9
 - data/Rakefile +8 -6
 - data/Rakefile.cross +57 -56
 - data/ext/errorcodes.def +64 -0
 - data/ext/errorcodes.txt +18 -2
 - data/ext/extconf.rb +6 -6
 - data/ext/pg.c +132 -95
 - data/ext/pg.h +21 -18
 - data/ext/pg_binary_decoder.c +9 -9
 - data/ext/pg_binary_encoder.c +13 -12
 - data/ext/pg_coder.c +21 -9
 - data/ext/pg_connection.c +388 -298
 - data/ext/pg_copy_coder.c +6 -3
 - data/ext/pg_record_coder.c +491 -0
 - data/ext/pg_result.c +279 -127
 - data/ext/pg_text_decoder.c +14 -8
 - data/ext/pg_text_encoder.c +180 -48
 - data/ext/pg_tuple.c +14 -6
 - data/ext/pg_type_map.c +1 -1
 - data/ext/pg_type_map_all_strings.c +4 -4
 - data/ext/pg_type_map_by_class.c +9 -4
 - data/ext/pg_type_map_by_column.c +7 -6
 - data/ext/pg_type_map_by_mri_type.c +1 -1
 - data/ext/pg_type_map_by_oid.c +3 -2
 - data/ext/pg_type_map_in_ruby.c +1 -1
 - data/ext/{util.c → pg_util.c} +5 -5
 - data/ext/{util.h → pg_util.h} +0 -0
 - data/lib/pg.rb +4 -4
 - data/lib/pg/basic_type_mapping.rb +81 -18
 - data/lib/pg/binary_decoder.rb +1 -0
 - data/lib/pg/coder.rb +22 -1
 - data/lib/pg/connection.rb +2 -2
 - data/lib/pg/constants.rb +1 -0
 - data/lib/pg/exceptions.rb +1 -0
 - data/lib/pg/result.rb +13 -1
 - data/lib/pg/text_decoder.rb +2 -3
 - data/lib/pg/text_encoder.rb +8 -18
 - data/lib/pg/type_map_by_column.rb +2 -1
 - data/spec/helpers.rb +11 -11
 - data/spec/pg/basic_type_mapping_spec.rb +140 -18
 - data/spec/pg/connection_spec.rb +166 -89
 - data/spec/pg/result_spec.rb +194 -4
 - data/spec/pg/tuple_spec.rb +55 -2
 - data/spec/pg/type_map_by_class_spec.rb +1 -1
 - data/spec/pg/type_map_by_column_spec.rb +5 -1
 - data/spec/pg/type_map_by_oid_spec.rb +2 -2
 - data/spec/pg/type_spec.rb +180 -6
 - metadata +31 -30
 - metadata.gz.sig +0 -0
 
    
        data/spec/pg/type_spec.rb
    CHANGED
    
    | 
         @@ -12,6 +12,7 @@ describe "PG::Type derivations" do 
     | 
|
| 
       12 
12 
     | 
    
         
             
            	let!(:textdec_boolean) { PG::TextDecoder::Boolean.new }
         
     | 
| 
       13 
13 
     | 
    
         
             
            	let!(:textenc_float) { PG::TextEncoder::Float.new }
         
     | 
| 
       14 
14 
     | 
    
         
             
            	let!(:textdec_float) { PG::TextDecoder::Float.new }
         
     | 
| 
      
 15 
     | 
    
         
            +
            	let!(:textenc_numeric) { PG::TextEncoder::Numeric.new }
         
     | 
| 
       15 
16 
     | 
    
         
             
            	let!(:textenc_string) { PG::TextEncoder::String.new }
         
     | 
| 
       16 
17 
     | 
    
         
             
            	let!(:textdec_string) { PG::TextDecoder::String.new }
         
     | 
| 
       17 
18 
     | 
    
         
             
            	let!(:textenc_timestamp) { PG::TextEncoder::TimestampWithoutTimeZone.new }
         
     | 
| 
         @@ -254,6 +255,11 @@ describe "PG::Type derivations" do 
     | 
|
| 
       254 
255 
     | 
    
         
             
            				expect( textdec_string.decode( nil )).to be_nil
         
     | 
| 
       255 
256 
     | 
    
         
             
            				expect( textdec_int.decode( nil )).to be_nil
         
     | 
| 
       256 
257 
     | 
    
         
             
            			end
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
            			it "should be defined on an encoder but not on a decoder instance" do
         
     | 
| 
      
 260 
     | 
    
         
            +
            				expect( textdec_int.respond_to?(:decode) ).to be_truthy
         
     | 
| 
      
 261 
     | 
    
         
            +
            				expect( textenc_int.respond_to?(:decode) ).to be_falsey
         
     | 
| 
      
 262 
     | 
    
         
            +
            			end
         
     | 
| 
       257 
263 
     | 
    
         
             
            		end
         
     | 
| 
       258 
264 
     | 
    
         | 
| 
       259 
265 
     | 
    
         
             
            		describe '#encode' do
         
     | 
| 
         @@ -304,12 +310,73 @@ describe "PG::Type derivations" do 
     | 
|
| 
       304 
310 
     | 
    
         
             
            				end
         
     | 
| 
       305 
311 
     | 
    
         
             
            			end
         
     | 
| 
       306 
312 
     | 
    
         | 
| 
      
 313 
     | 
    
         
            +
            			it "should encode floats" do
         
     | 
| 
      
 314 
     | 
    
         
            +
            				expect( textenc_float.encode(0) ).to eq( "0.0" )
         
     | 
| 
      
 315 
     | 
    
         
            +
            				expect( textenc_float.encode(-1) ).to eq( "-1.0" )
         
     | 
| 
      
 316 
     | 
    
         
            +
            				expect( textenc_float.encode(-1.234567890123456789) ).to eq( "-1.234567890123457" )
         
     | 
| 
      
 317 
     | 
    
         
            +
            				expect( textenc_float.encode(9) ).to eq( "9.0" )
         
     | 
| 
      
 318 
     | 
    
         
            +
            				expect( textenc_float.encode(10) ).to eq( "10.0" )
         
     | 
| 
      
 319 
     | 
    
         
            +
            				expect( textenc_float.encode(-99) ).to eq( "-99.0" )
         
     | 
| 
      
 320 
     | 
    
         
            +
            				expect( textenc_float.encode(-100) ).to eq( "-100.0" )
         
     | 
| 
      
 321 
     | 
    
         
            +
            				expect( textenc_float.encode(999) ).to eq( "999.0" )
         
     | 
| 
      
 322 
     | 
    
         
            +
            				expect( textenc_float.encode(-1000) ).to eq( "-1000.0" )
         
     | 
| 
      
 323 
     | 
    
         
            +
            				expect( textenc_float.encode(1234.567890123456789) ).to eq( "1234.567890123457" )
         
     | 
| 
      
 324 
     | 
    
         
            +
            				expect( textenc_float.encode(-9999) ).to eq( "-9999.0" )
         
     | 
| 
      
 325 
     | 
    
         
            +
            				expect( textenc_float.encode(10000) ).to eq( "10000.0" )
         
     | 
| 
      
 326 
     | 
    
         
            +
            				expect( textenc_float.encode(99999) ).to eq( "99999.0" )
         
     | 
| 
      
 327 
     | 
    
         
            +
            				expect( textenc_float.encode(-100000) ).to eq( "-100000.0" )
         
     | 
| 
      
 328 
     | 
    
         
            +
            				expect( textenc_float.encode(-999999) ).to eq( "-999999.0" )
         
     | 
| 
      
 329 
     | 
    
         
            +
            				expect( textenc_float.encode(1000000) ).to eq( "1000000.0" )
         
     | 
| 
      
 330 
     | 
    
         
            +
            				expect( textenc_float.encode(9999999) ).to eq( "9999999.0" )
         
     | 
| 
      
 331 
     | 
    
         
            +
            				expect( textenc_float.encode(-100000000000000) ).to eq( "-100000000000000.0" )
         
     | 
| 
      
 332 
     | 
    
         
            +
            				expect( textenc_float.encode(123456789012345) ).to eq( "123456789012345.0" )
         
     | 
| 
      
 333 
     | 
    
         
            +
            				expect( textenc_float.encode(-999999999999999) ).to eq( "-999999999999999.0" )
         
     | 
| 
      
 334 
     | 
    
         
            +
            				expect( textenc_float.encode(1000000000000000) ).to eq( "1e15" )
         
     | 
| 
      
 335 
     | 
    
         
            +
            				expect( textenc_float.encode(-1234567890123456) ).to eq( "-1.234567890123456e15" )
         
     | 
| 
      
 336 
     | 
    
         
            +
            				expect( textenc_float.encode(9999999999999999) ).to eq( "1e16" )
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.0) ).to eq( "0.0" )
         
     | 
| 
      
 339 
     | 
    
         
            +
            				expect( textenc_float.encode(0.1) ).to eq( "0.1" )
         
     | 
| 
      
 340 
     | 
    
         
            +
            				expect( textenc_float.encode(0.1234567890123456789) ).to eq( "0.1234567890123457" )
         
     | 
| 
      
 341 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.9) ).to eq( "-0.9" )
         
     | 
| 
      
 342 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.01234567890123456789) ).to eq( "-0.01234567890123457" )
         
     | 
| 
      
 343 
     | 
    
         
            +
            				expect( textenc_float.encode(0.09) ).to eq( "0.09" )
         
     | 
| 
      
 344 
     | 
    
         
            +
            				expect( textenc_float.encode(0.001234567890123456789) ).to eq( "0.001234567890123457" )
         
     | 
| 
      
 345 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.009) ).to eq( "-0.009" )
         
     | 
| 
      
 346 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.0001234567890123456789) ).to eq( "-0.0001234567890123457" )
         
     | 
| 
      
 347 
     | 
    
         
            +
            				expect( textenc_float.encode(0.0009) ).to eq( "0.0009" )
         
     | 
| 
      
 348 
     | 
    
         
            +
            				expect( textenc_float.encode(0.00001) ).to eq( "1e-5" )
         
     | 
| 
      
 349 
     | 
    
         
            +
            				expect( textenc_float.encode(0.00001234567890123456789) ).to eq( "1.234567890123457e-5" )
         
     | 
| 
      
 350 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.00009) ).to eq( "-9e-5" )
         
     | 
| 
      
 351 
     | 
    
         
            +
            				expect( textenc_float.encode(-0.11) ).to eq( "-0.11" )
         
     | 
| 
      
 352 
     | 
    
         
            +
            				expect( textenc_float.encode(10.11) ).to eq( "10.11" )
         
     | 
| 
      
 353 
     | 
    
         
            +
            				expect( textenc_float.encode(-1.234567890123456789E-280) ).to eq( "-1.234567890123457e-280" )
         
     | 
| 
      
 354 
     | 
    
         
            +
            				expect( textenc_float.encode(-1.234567890123456789E280) ).to eq( "-1.234567890123457e280" )
         
     | 
| 
      
 355 
     | 
    
         
            +
            				expect( textenc_float.encode(9876543210987654321E280) ).to eq( "9.87654321098765e298" )
         
     | 
| 
      
 356 
     | 
    
         
            +
            				expect( textenc_float.encode(9876543210987654321E-400) ).to eq( "0.0" )
         
     | 
| 
      
 357 
     | 
    
         
            +
            				expect( textenc_float.encode(9876543210987654321E400) ).to eq( "Infinity" )
         
     | 
| 
      
 358 
     | 
    
         
            +
            			end
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
       307 
360 
     | 
    
         
             
            			it "should encode special floats equally to Float#to_s" do
         
     | 
| 
       308 
361 
     | 
    
         
             
            				expect( textenc_float.encode(Float::INFINITY) ).to eq( Float::INFINITY.to_s )
         
     | 
| 
       309 
362 
     | 
    
         
             
            				expect( textenc_float.encode(-Float::INFINITY) ).to eq( (-Float::INFINITY).to_s )
         
     | 
| 
       310 
363 
     | 
    
         
             
            				expect( textenc_float.encode(-Float::NAN) ).to eq( Float::NAN.to_s )
         
     | 
| 
       311 
364 
     | 
    
         
             
            			end
         
     | 
| 
       312 
365 
     | 
    
         | 
| 
      
 366 
     | 
    
         
            +
            			it "should encode various inputs to numeric format" do
         
     | 
| 
      
 367 
     | 
    
         
            +
            				expect( textenc_numeric.encode(0) ).to eq( "0" )
         
     | 
| 
      
 368 
     | 
    
         
            +
            				expect( textenc_numeric.encode(1) ).to eq( "1" )
         
     | 
| 
      
 369 
     | 
    
         
            +
            				expect( textenc_numeric.encode(-12345678901234567890123) ).to eq( "-12345678901234567890123" )
         
     | 
| 
      
 370 
     | 
    
         
            +
            				expect( textenc_numeric.encode(0.0) ).to eq( "0.0" )
         
     | 
| 
      
 371 
     | 
    
         
            +
            				expect( textenc_numeric.encode(1.0) ).to eq( "1.0" )
         
     | 
| 
      
 372 
     | 
    
         
            +
            				expect( textenc_numeric.encode(-1.23456789012e45) ).to eq( "-1.23456789012e45" )
         
     | 
| 
      
 373 
     | 
    
         
            +
            				expect( textenc_numeric.encode(Float::NAN) ).to eq( Float::NAN.to_s )
         
     | 
| 
      
 374 
     | 
    
         
            +
            				expect( textenc_numeric.encode(BigDecimal(0)) ).to eq( "0.0" )
         
     | 
| 
      
 375 
     | 
    
         
            +
            				expect( textenc_numeric.encode(BigDecimal(1)) ).to eq( "1.0" )
         
     | 
| 
      
 376 
     | 
    
         
            +
            				expect( textenc_numeric.encode(BigDecimal("-12345678901234567890.1234567")) ).to eq( "-12345678901234567890.1234567" )
         
     | 
| 
      
 377 
     | 
    
         
            +
            				expect( textenc_numeric.encode(" 123 ") ).to eq( " 123 " )
         
     | 
| 
      
 378 
     | 
    
         
            +
            			end
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
       313 
380 
     | 
    
         
             
            			it "encodes binary string to bytea" do
         
     | 
| 
       314 
381 
     | 
    
         
             
            				expect( textenc_bytea.encode("\x00\x01\x02\x03\xef".b) ).to eq( "\\x00010203ef" )
         
     | 
| 
       315 
382 
     | 
    
         
             
            			end
         
     | 
| 
         @@ -376,6 +443,11 @@ describe "PG::Type derivations" do 
     | 
|
| 
       376 
443 
     | 
    
         
             
            				expect( textenc_string.encode( nil )).to be_nil
         
     | 
| 
       377 
444 
     | 
    
         
             
            				expect( textenc_int.encode( nil )).to be_nil
         
     | 
| 
       378 
445 
     | 
    
         
             
            			end
         
     | 
| 
      
 446 
     | 
    
         
            +
             
     | 
| 
      
 447 
     | 
    
         
            +
            			it "should be defined on a decoder but not on an encoder instance" do
         
     | 
| 
      
 448 
     | 
    
         
            +
            				expect( textenc_int.respond_to?(:encode) ).to be_truthy
         
     | 
| 
      
 449 
     | 
    
         
            +
            				expect( textdec_int.respond_to?(:encode) ).to be_falsey
         
     | 
| 
      
 450 
     | 
    
         
            +
            			end
         
     | 
| 
       379 
451 
     | 
    
         
             
            		end
         
     | 
| 
       380 
452 
     | 
    
         | 
| 
       381 
453 
     | 
    
         
             
            		it "should be possible to marshal encoders" do
         
     | 
| 
         @@ -392,7 +464,7 @@ describe "PG::Type derivations" do 
     | 
|
| 
       392 
464 
     | 
    
         | 
| 
       393 
465 
     | 
    
         
             
            		it "should respond to to_h" do
         
     | 
| 
       394 
466 
     | 
    
         
             
            			expect( textenc_int.to_h ).to eq( {
         
     | 
| 
       395 
     | 
    
         
            -
            				name: 'Integer', oid: 23, format: 0
         
     | 
| 
      
 467 
     | 
    
         
            +
            				name: 'Integer', oid: 23, format: 0, flags: 0
         
     | 
| 
       396 
468 
     | 
    
         
             
            			} )
         
     | 
| 
       397 
469 
     | 
    
         
             
            		end
         
     | 
| 
       398 
470 
     | 
    
         | 
| 
         @@ -624,7 +696,7 @@ describe "PG::Type derivations" do 
     | 
|
| 
       624 
696 
     | 
    
         
             
            						expect( textenc_int_array.encode(['1',['2'],'3']) ).to eq( %[{1,{2},3}] )
         
     | 
| 
       625 
697 
     | 
    
         
             
            					end
         
     | 
| 
       626 
698 
     | 
    
         
             
            					it 'encodes an array of float8 with sub arrays' do
         
     | 
| 
       627 
     | 
    
         
            -
            						expect( textenc_float_array.encode([1000.11,[-0. 
     | 
| 
      
 699 
     | 
    
         
            +
            						expect( textenc_float_array.encode([1000.11,[-0.00000221,[3.31,-441]],[nil,6.61],-7.71]) ).to match(Regexp.new(%[^{1000.1*,{-2.2*e-*6,{3.3*,-441.0}},{NULL,6.6*},-7.7*}$].gsub(/([\.\+\{\}\,])/, "\\\\\\1").gsub(/\*/, "\\d*")))
         
     | 
| 
       628 
700 
     | 
    
         
             
            					end
         
     | 
| 
       629 
701 
     | 
    
         
             
            				end
         
     | 
| 
       630 
702 
     | 
    
         
             
            				context 'two dimensional arrays' do
         
     | 
| 
         @@ -712,15 +784,15 @@ describe "PG::Type derivations" do 
     | 
|
| 
       712 
784 
     | 
    
         
             
            				expect( lt.to_h ).to eq( textenc_int_array.to_h )
         
     | 
| 
       713 
785 
     | 
    
         
             
            			end
         
     | 
| 
       714 
786 
     | 
    
         | 
| 
       715 
     | 
    
         
            -
            			it "should be possible to marshal  
     | 
| 
       716 
     | 
    
         
            -
            				mt = Marshal.dump( 
     | 
| 
      
 787 
     | 
    
         
            +
            			it "should be possible to marshal decoders" do
         
     | 
| 
      
 788 
     | 
    
         
            +
            				mt = Marshal.dump(textdec_string_array_raise)
         
     | 
| 
       717 
789 
     | 
    
         
             
            				lt = Marshal.load(mt)
         
     | 
| 
       718 
     | 
    
         
            -
            				expect( lt.to_h ).to eq(  
     | 
| 
      
 790 
     | 
    
         
            +
            				expect( lt.to_h ).to eq( textdec_string_array_raise.to_h )
         
     | 
| 
       719 
791 
     | 
    
         
             
            			end
         
     | 
| 
       720 
792 
     | 
    
         | 
| 
       721 
793 
     | 
    
         
             
            			it "should respond to to_h" do
         
     | 
| 
       722 
794 
     | 
    
         
             
            				expect( textenc_int_array.to_h ).to eq( {
         
     | 
| 
       723 
     | 
    
         
            -
            					name: nil, oid: 0, format: 0,
         
     | 
| 
      
 795 
     | 
    
         
            +
            					name: nil, oid: 0, format: 0, flags: 0,
         
     | 
| 
       724 
796 
     | 
    
         
             
            					elements_type: textenc_int, needs_quotation: false, delimiter: ','
         
     | 
| 
       725 
797 
     | 
    
         
             
            				} )
         
     | 
| 
       726 
798 
     | 
    
         
             
            			end
         
     | 
| 
         @@ -946,4 +1018,106 @@ describe "PG::Type derivations" do 
     | 
|
| 
       946 
1018 
     | 
    
         
             
            			end
         
     | 
| 
       947 
1019 
     | 
    
         
             
            		end
         
     | 
| 
       948 
1020 
     | 
    
         
             
            	end
         
     | 
| 
      
 1021 
     | 
    
         
            +
             
     | 
| 
      
 1022 
     | 
    
         
            +
            	describe PG::RecordCoder do
         
     | 
| 
      
 1023 
     | 
    
         
            +
            		describe PG::TextEncoder::Record do
         
     | 
| 
      
 1024 
     | 
    
         
            +
            			context "with default typemap" do
         
     | 
| 
      
 1025 
     | 
    
         
            +
            				let!(:encoder) do
         
     | 
| 
      
 1026 
     | 
    
         
            +
            					PG::TextEncoder::Record.new
         
     | 
| 
      
 1027 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1028 
     | 
    
         
            +
             
     | 
| 
      
 1029 
     | 
    
         
            +
            				it "should encode different types of Ruby objects" do
         
     | 
| 
      
 1030 
     | 
    
         
            +
            					expect( encoder.encode([:xyz, 123, 2456, 34567, 456789, 5678901, [1,2,3], 12.1, "abcdefg", nil]) ).
         
     | 
| 
      
 1031 
     | 
    
         
            +
            						to eq('("xyz","123","2456","34567","456789","5678901","[1, 2, 3]","12.1","abcdefg",)')
         
     | 
| 
      
 1032 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1033 
     | 
    
         
            +
             
     | 
| 
      
 1034 
     | 
    
         
            +
            				it 'should output a string with correct character encoding' do
         
     | 
| 
      
 1035 
     | 
    
         
            +
            					v = encoder.encode(["Héllo"], "iso-8859-1")
         
     | 
| 
      
 1036 
     | 
    
         
            +
            					expect( v.encoding ).to eq( Encoding::ISO_8859_1 )
         
     | 
| 
      
 1037 
     | 
    
         
            +
            					expect( v ).to eq( '("Héllo")'.encode(Encoding::ISO_8859_1) )
         
     | 
| 
      
 1038 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1039 
     | 
    
         
            +
            			end
         
     | 
| 
      
 1040 
     | 
    
         
            +
             
     | 
| 
      
 1041 
     | 
    
         
            +
            			context "with TypeMapByClass" do
         
     | 
| 
      
 1042 
     | 
    
         
            +
            				let!(:tm) do
         
     | 
| 
      
 1043 
     | 
    
         
            +
            					tm = PG::TypeMapByClass.new
         
     | 
| 
      
 1044 
     | 
    
         
            +
            					tm[Integer] = textenc_int
         
     | 
| 
      
 1045 
     | 
    
         
            +
            					tm[Float] = intenc_incrementer
         
     | 
| 
      
 1046 
     | 
    
         
            +
            					tm[Array] = PG::TextEncoder::Array.new elements_type: textenc_string
         
     | 
| 
      
 1047 
     | 
    
         
            +
            					tm
         
     | 
| 
      
 1048 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1049 
     | 
    
         
            +
            				let!(:encoder) do
         
     | 
| 
      
 1050 
     | 
    
         
            +
            					PG::TextEncoder::Record.new type_map: tm
         
     | 
| 
      
 1051 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1052 
     | 
    
         
            +
             
     | 
| 
      
 1053 
     | 
    
         
            +
            				it "should have reasonable default values" do
         
     | 
| 
      
 1054 
     | 
    
         
            +
            					expect( encoder.name ).to be_nil
         
     | 
| 
      
 1055 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1056 
     | 
    
         
            +
             
     | 
| 
      
 1057 
     | 
    
         
            +
            				it "copies all attributes with #dup" do
         
     | 
| 
      
 1058 
     | 
    
         
            +
            					encoder.name = "test"
         
     | 
| 
      
 1059 
     | 
    
         
            +
            					encoder.type_map = PG::TypeMapByColumn.new []
         
     | 
| 
      
 1060 
     | 
    
         
            +
            					encoder2 = encoder.dup
         
     | 
| 
      
 1061 
     | 
    
         
            +
            					expect( encoder.object_id ).to_not eq( encoder2.object_id )
         
     | 
| 
      
 1062 
     | 
    
         
            +
            					expect( encoder2.name ).to eq( "test" )
         
     | 
| 
      
 1063 
     | 
    
         
            +
            					expect( encoder2.type_map ).to be_a_kind_of( PG::TypeMapByColumn )
         
     | 
| 
      
 1064 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1065 
     | 
    
         
            +
             
     | 
| 
      
 1066 
     | 
    
         
            +
            				describe '#encode' do
         
     | 
| 
      
 1067 
     | 
    
         
            +
            					it "should encode different types of Ruby objects" do
         
     | 
| 
      
 1068 
     | 
    
         
            +
            						expect( encoder.encode([]) ).to eq("()")
         
     | 
| 
      
 1069 
     | 
    
         
            +
            						expect( encoder.encode(["a"]) ).to eq('("a")')
         
     | 
| 
      
 1070 
     | 
    
         
            +
            						expect( encoder.encode([:xyz, 123, 2456, 34567, 456789, 5678901, [1,2,3], 12.1, "abcdefg", nil]) ).
         
     | 
| 
      
 1071 
     | 
    
         
            +
            							to eq('("xyz","123","2456","34567","456789","5678901","{1,2,3}","13 ","abcdefg",)')
         
     | 
| 
      
 1072 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1073 
     | 
    
         
            +
             
     | 
| 
      
 1074 
     | 
    
         
            +
            					it "should escape special characters" do
         
     | 
| 
      
 1075 
     | 
    
         
            +
            						expect( encoder.encode([" \"\t\n\\\r"]) ).to eq("(\" \"\"\t\n##\r\")".gsub("#", "\\"))
         
     | 
| 
      
 1076 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1077 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1078 
     | 
    
         
            +
            			end
         
     | 
| 
      
 1079 
     | 
    
         
            +
            		end
         
     | 
| 
      
 1080 
     | 
    
         
            +
             
     | 
| 
      
 1081 
     | 
    
         
            +
            		describe PG::TextDecoder::Record do
         
     | 
| 
      
 1082 
     | 
    
         
            +
            			context "with default typemap" do
         
     | 
| 
      
 1083 
     | 
    
         
            +
            				let!(:decoder) do
         
     | 
| 
      
 1084 
     | 
    
         
            +
            					PG::TextDecoder::Record.new
         
     | 
| 
      
 1085 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1086 
     | 
    
         
            +
             
     | 
| 
      
 1087 
     | 
    
         
            +
            				describe '#decode' do
         
     | 
| 
      
 1088 
     | 
    
         
            +
            					it "should decode composite text format to array of strings" do
         
     | 
| 
      
 1089 
     | 
    
         
            +
            						expect( decoder.decode('("fuzzy dice",,"",42,)') ).to eq( ["fuzzy dice",nil, "", "42", nil] )
         
     | 
| 
      
 1090 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1091 
     | 
    
         
            +
             
     | 
| 
      
 1092 
     | 
    
         
            +
            					it 'should respect input character encoding' do
         
     | 
| 
      
 1093 
     | 
    
         
            +
            						v = decoder.decode("(Héllo)".encode("iso-8859-1")).first
         
     | 
| 
      
 1094 
     | 
    
         
            +
            						expect( v.encoding ).to eq(Encoding::ISO_8859_1)
         
     | 
| 
      
 1095 
     | 
    
         
            +
            						expect( v ).to eq("Héllo".encode("iso-8859-1"))
         
     | 
| 
      
 1096 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1097 
     | 
    
         
            +
             
     | 
| 
      
 1098 
     | 
    
         
            +
            					it 'should raise an error on malformed input' do
         
     | 
| 
      
 1099 
     | 
    
         
            +
            						expect{ decoder.decode('') }.to raise_error(ArgumentError, /"" - Missing left parenthesis/)
         
     | 
| 
      
 1100 
     | 
    
         
            +
            						expect{ decoder.decode('(') }.to raise_error(ArgumentError, /"\(" - Unexpected end of input/)
         
     | 
| 
      
 1101 
     | 
    
         
            +
            						expect{ decoder.decode('(\\') }.to raise_error(ArgumentError, /"\(\\" - Unexpected end of input/)
         
     | 
| 
      
 1102 
     | 
    
         
            +
            						expect{ decoder.decode('()x') }.to raise_error(ArgumentError, /"\(\)x" - Junk after right parenthesis/)
         
     | 
| 
      
 1103 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1104 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1105 
     | 
    
         
            +
            			end
         
     | 
| 
      
 1106 
     | 
    
         
            +
             
     | 
| 
      
 1107 
     | 
    
         
            +
            			context "with TypeMapByColumn" do
         
     | 
| 
      
 1108 
     | 
    
         
            +
            				let!(:tm) do
         
     | 
| 
      
 1109 
     | 
    
         
            +
            					PG::TypeMapByColumn.new [textdec_int, textdec_string, intdec_incrementer, nil]
         
     | 
| 
      
 1110 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1111 
     | 
    
         
            +
            				let!(:decoder) do
         
     | 
| 
      
 1112 
     | 
    
         
            +
            					PG::TextDecoder::Record.new type_map: tm
         
     | 
| 
      
 1113 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1114 
     | 
    
         
            +
             
     | 
| 
      
 1115 
     | 
    
         
            +
            				describe '#decode' do
         
     | 
| 
      
 1116 
     | 
    
         
            +
            					it "should decode different types of Ruby objects" do
         
     | 
| 
      
 1117 
     | 
    
         
            +
            						expect( decoder.decode("(123,\" #,#\n#\r#\\ \",234,#\x01#\002)".gsub("#", "\\"))).to eq( [123, " ,\n\r\\ ", 235, "\x01\x02"] )
         
     | 
| 
      
 1118 
     | 
    
         
            +
            					end
         
     | 
| 
      
 1119 
     | 
    
         
            +
            				end
         
     | 
| 
      
 1120 
     | 
    
         
            +
            			end
         
     | 
| 
      
 1121 
     | 
    
         
            +
            		end
         
     | 
| 
      
 1122 
     | 
    
         
            +
            	end
         
     | 
| 
       949 
1123 
     | 
    
         
             
            end
         
     | 
    
        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: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Michael Granger
         
     | 
| 
         @@ -11,9 +11,9 @@ bindir: bin 
     | 
|
| 
       11 
11 
     | 
    
         
             
            cert_chain:
         
     | 
| 
       12 
12 
     | 
    
         
             
            - |
         
     | 
| 
       13 
13 
     | 
    
         
             
              -----BEGIN CERTIFICATE-----
         
     | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
       16 
     | 
    
         
            -
               
     | 
| 
      
 14 
     | 
    
         
            +
              MIID+DCCAmCgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
         
     | 
| 
      
 15 
     | 
    
         
            +
              REM9RmFlcmllTVVEL0RDPW9yZzAeFw0xOTEyMjQyMDE5NTFaFw0yMDEyMjMyMDE5
         
     | 
| 
      
 16 
     | 
    
         
            +
              NTFaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
         
     | 
| 
       17 
17 
     | 
    
         
             
              hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
         
     | 
| 
       18 
18 
     | 
    
         
             
              L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
         
     | 
| 
       19 
19 
     | 
    
         
             
              M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
         
     | 
| 
         @@ -22,20 +22,19 @@ cert_chain: 
     | 
|
| 
       22 
22 
     | 
    
         
             
              vQ66lts4alKC69TE5cuKasWBm+16A4aEe3XdZBRNmtOu/g81gvwA7fkJHKllJuaI
         
     | 
| 
       23 
23 
     | 
    
         
             
              dXzdHqq+zbGZVSQ7pRYHYomD0IiDe1DbIouFnPWmagaBnGHwXkDT2bKKP+s2v21m
         
     | 
| 
       24 
24 
     | 
    
         
             
              ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
         
     | 
| 
       25 
     | 
    
         
            -
              N2I4L/ZOIe2DIVuYH7aLHfjZDQv/ 
     | 
| 
       26 
     | 
    
         
            -
               
     | 
| 
       27 
     | 
    
         
            -
               
     | 
| 
       28 
     | 
    
         
            -
               
     | 
| 
       29 
     | 
    
         
            -
               
     | 
| 
       30 
     | 
    
         
            -
               
     | 
| 
       31 
     | 
    
         
            -
               
     | 
| 
       32 
     | 
    
         
            -
               
     | 
| 
       33 
     | 
    
         
            -
               
     | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
       35 
     | 
    
         
            -
               
     | 
| 
       36 
     | 
    
         
            -
              JnC4lpJfCP6aCXa5h2XAQfPSH636cQap
         
     | 
| 
      
 25 
     | 
    
         
            +
              N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
         
     | 
| 
      
 26 
     | 
    
         
            +
              VR0PBAQDAgSwMB0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
         
     | 
| 
      
 27 
     | 
    
         
            +
              9w0BAQsFAAOCAYEAifxlz7x0EfT3fjhM520ZEIrWa+tLMuLKNefkY18u8tZnx4EX
         
     | 
| 
      
 28 
     | 
    
         
            +
              Xxwh3tna3fvNfrOrdY5leIj1dbv4FTRg+gIBnIxAySqvpGvI/Axg5EdYbwninCLL
         
     | 
| 
      
 29 
     | 
    
         
            +
              LAKCmRo+5QwaPMYN2zdHIjGrp8jg1neCo5zy6tVvyTv0DMI6FLrydVJYduMMDFSy
         
     | 
| 
      
 30 
     | 
    
         
            +
              gQKR1rVOcCJtnBnLCF9+kKEUKohAHOmGsE7OBZFnjMIpH5yUDUVJKByv0gIipFt0
         
     | 
| 
      
 31 
     | 
    
         
            +
              1T6zff6oVU0w8WBiNKR381+6sF3wIZVnVY0XeJg6hNL+YecE8ILxLhHTmtT/BO0S
         
     | 
| 
      
 32 
     | 
    
         
            +
              3xPze9uXDR+iD6HYl8KU5QEg/dXFPhfQb512vVkTJDZvMcwu6PxDUjHFChLjAji/
         
     | 
| 
      
 33 
     | 
    
         
            +
              AZXjg1C5E9znTkeUR8ieU9F1MOKoiH57a5lYSTI8Ga8PpsNXTxNeXc16Ob26CqrJ
         
     | 
| 
      
 34 
     | 
    
         
            +
              83uuAYSy65yXDGXXPVBeKPVnYrqp91pqpS5Nh7wfuiCrE8lgU8PATh7K4BV1UhAT
         
     | 
| 
      
 35 
     | 
    
         
            +
              0MHbAT42wTYkfUj3
         
     | 
| 
       37 
36 
     | 
    
         
             
              -----END CERTIFICATE-----
         
     | 
| 
       38 
     | 
    
         
            -
            date:  
     | 
| 
      
 37 
     | 
    
         
            +
            date: 2020-03-18 00:00:00.000000000 Z
         
     | 
| 
       39 
38 
     | 
    
         
             
            dependencies:
         
     | 
| 
       40 
39 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       41 
40 
     | 
    
         
             
              name: hoe-mercurial
         
     | 
| 
         @@ -99,14 +98,14 @@ dependencies: 
     | 
|
| 
       99 
98 
     | 
    
         
             
                requirements:
         
     | 
| 
       100 
99 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       101 
100 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       102 
     | 
    
         
            -
                    version:  
     | 
| 
      
 101 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
       103 
102 
     | 
    
         
             
              type: :development
         
     | 
| 
       104 
103 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       105 
104 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       106 
105 
     | 
    
         
             
                requirements:
         
     | 
| 
       107 
106 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       108 
107 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       109 
     | 
    
         
            -
                    version:  
     | 
| 
      
 108 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
       110 
109 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       111 
110 
     | 
    
         
             
              name: hoe-bundler
         
     | 
| 
       112 
111 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -155,14 +154,14 @@ dependencies: 
     | 
|
| 
       155 
154 
     | 
    
         
             
                requirements:
         
     | 
| 
       156 
155 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       157 
156 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       158 
     | 
    
         
            -
                    version: '3. 
     | 
| 
      
 157 
     | 
    
         
            +
                    version: '3.20'
         
     | 
| 
       159 
158 
     | 
    
         
             
              type: :development
         
     | 
| 
       160 
159 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       161 
160 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       162 
161 
     | 
    
         
             
                requirements:
         
     | 
| 
       163 
162 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       164 
163 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       165 
     | 
    
         
            -
                    version: '3. 
     | 
| 
      
 164 
     | 
    
         
            +
                    version: '3.20'
         
     | 
| 
       166 
165 
     | 
    
         
             
            description: |-
         
     | 
| 
       167 
166 
     | 
    
         
             
              Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
         
     | 
| 
       168 
167 
     | 
    
         | 
| 
         @@ -208,6 +207,7 @@ extra_rdoc_files: 
     | 
|
| 
       208 
207 
     | 
    
         
             
            - ext/pg_connection.c
         
     | 
| 
       209 
208 
     | 
    
         
             
            - ext/pg_copy_coder.c
         
     | 
| 
       210 
209 
     | 
    
         
             
            - ext/pg_errors.c
         
     | 
| 
      
 210 
     | 
    
         
            +
            - ext/pg_record_coder.c
         
     | 
| 
       211 
211 
     | 
    
         
             
            - ext/pg_result.c
         
     | 
| 
       212 
212 
     | 
    
         
             
            - ext/pg_text_decoder.c
         
     | 
| 
       213 
213 
     | 
    
         
             
            - ext/pg_text_encoder.c
         
     | 
| 
         @@ -219,7 +219,7 @@ extra_rdoc_files: 
     | 
|
| 
       219 
219 
     | 
    
         
             
            - ext/pg_type_map_by_mri_type.c
         
     | 
| 
       220 
220 
     | 
    
         
             
            - ext/pg_type_map_by_oid.c
         
     | 
| 
       221 
221 
     | 
    
         
             
            - ext/pg_type_map_in_ruby.c
         
     | 
| 
       222 
     | 
    
         
            -
            - ext/ 
     | 
| 
      
 222 
     | 
    
         
            +
            - ext/pg_util.c
         
     | 
| 
       223 
223 
     | 
    
         
             
            files:
         
     | 
| 
       224 
224 
     | 
    
         
             
            - ".gemtest"
         
     | 
| 
       225 
225 
     | 
    
         
             
            - BSDL
         
     | 
| 
         @@ -249,6 +249,7 @@ files: 
     | 
|
| 
       249 
249 
     | 
    
         
             
            - ext/pg_connection.c
         
     | 
| 
       250 
250 
     | 
    
         
             
            - ext/pg_copy_coder.c
         
     | 
| 
       251 
251 
     | 
    
         
             
            - ext/pg_errors.c
         
     | 
| 
      
 252 
     | 
    
         
            +
            - ext/pg_record_coder.c
         
     | 
| 
       252 
253 
     | 
    
         
             
            - ext/pg_result.c
         
     | 
| 
       253 
254 
     | 
    
         
             
            - ext/pg_text_decoder.c
         
     | 
| 
       254 
255 
     | 
    
         
             
            - ext/pg_text_encoder.c
         
     | 
| 
         @@ -260,8 +261,8 @@ files: 
     | 
|
| 
       260 
261 
     | 
    
         
             
            - ext/pg_type_map_by_mri_type.c
         
     | 
| 
       261 
262 
     | 
    
         
             
            - ext/pg_type_map_by_oid.c
         
     | 
| 
       262 
263 
     | 
    
         
             
            - ext/pg_type_map_in_ruby.c
         
     | 
| 
       263 
     | 
    
         
            -
            - ext/ 
     | 
| 
       264 
     | 
    
         
            -
            - ext/ 
     | 
| 
      
 264 
     | 
    
         
            +
            - ext/pg_util.c
         
     | 
| 
      
 265 
     | 
    
         
            +
            - ext/pg_util.h
         
     | 
| 
       265 
266 
     | 
    
         
             
            - ext/vc/pg.sln
         
     | 
| 
       266 
267 
     | 
    
         
             
            - ext/vc/pg_18/pg.vcproj
         
     | 
| 
       267 
268 
     | 
    
         
             
            - ext/vc/pg_19/pg_19.vcproj
         
     | 
| 
         @@ -293,10 +294,11 @@ files: 
     | 
|
| 
       293 
294 
     | 
    
         
             
            - spec/pg/type_map_spec.rb
         
     | 
| 
       294 
295 
     | 
    
         
             
            - spec/pg/type_spec.rb
         
     | 
| 
       295 
296 
     | 
    
         
             
            - spec/pg_spec.rb
         
     | 
| 
       296 
     | 
    
         
            -
            homepage: https:// 
     | 
| 
      
 297 
     | 
    
         
            +
            homepage: https://github.com/ged/ruby-pg
         
     | 
| 
       297 
298 
     | 
    
         
             
            licenses:
         
     | 
| 
       298 
     | 
    
         
            -
            - BSD- 
     | 
| 
       299 
     | 
    
         
            -
            metadata: 
     | 
| 
      
 299 
     | 
    
         
            +
            - BSD-2-Clause
         
     | 
| 
      
 300 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 301 
     | 
    
         
            +
              homepage_uri: https://github.com/ged/ruby-pg
         
     | 
| 
       300 
302 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       301 
303 
     | 
    
         
             
            rdoc_options:
         
     | 
| 
       302 
304 
     | 
    
         
             
            - "--main"
         
     | 
| 
         @@ -307,15 +309,14 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       307 
309 
     | 
    
         
             
              requirements:
         
     | 
| 
       308 
310 
     | 
    
         
             
              - - ">="
         
     | 
| 
       309 
311 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       310 
     | 
    
         
            -
                  version: 2. 
     | 
| 
      
 312 
     | 
    
         
            +
                  version: '2.2'
         
     | 
| 
       311 
313 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       312 
314 
     | 
    
         
             
              requirements:
         
     | 
| 
       313 
315 
     | 
    
         
             
              - - ">="
         
     | 
| 
       314 
316 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       315 
317 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       316 
318 
     | 
    
         
             
            requirements: []
         
     | 
| 
       317 
     | 
    
         
            -
             
     | 
| 
       318 
     | 
    
         
            -
            rubygems_version: 2.7.8
         
     | 
| 
      
 319 
     | 
    
         
            +
            rubygems_version: 3.0.6
         
     | 
| 
       319 
320 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       320 
321 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       321 
322 
     | 
    
         
             
            summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |