Skip to content

Commit

Permalink
Verify that typemaps are applied to stream_each_tuple
Browse files Browse the repository at this point in the history
This currently fails.
  • Loading branch information
larskanis committed Nov 12, 2019
1 parent a0015da commit 1191f40
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/pg/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
end

context "result streaming in single row mode" do
let!(:textdec_int){ PG::TextDecoder::Integer.new name: 'INT4', oid: 23 }

it "can iterate over all rows as Hash" do
@conn.send_query( "SELECT generate_series(2,4) AS a; SELECT 1 AS b, generate_series(5,6) AS c" )
@conn.set_single_row_mode
Expand Down Expand Up @@ -145,13 +147,14 @@
expect( @conn.get_result ).to be_nil
end

it "can iterate over all rows as PG::Tuple with symbols" do
it "can iterate over all rows as PG::Tuple with symbols and typemap" do
@conn.send_query( "SELECT generate_series(2,4) AS a" )
@conn.set_single_row_mode
res = @conn.get_result.field_names_as(:symbol)
res.type_map = PG::TypeMapByColumn.new [textdec_int]
tuples = res.stream_each_tuple.to_a
expect( tuples[0][0] ).to eq( "2" )
expect( tuples[1][:a] ).to eq( "3" )
expect( tuples[0][0] ).to eq( 2 )
expect( tuples[1][:a] ).to eq( 3 )
expect( @conn.get_result ).to be_nil
end

Expand Down

0 comments on commit 1191f40

Please sign in to comment.