Skip to content

Commit

Permalink
Merge pull request #579 from larskanis/add-record-to-btm
Browse files Browse the repository at this point in the history
Add default decoder for anonymous record types to BasicTypeRegistry
  • Loading branch information
larskanis authored Aug 12, 2024
2 parents 35510e2 + 761b272 commit beafa09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/pg/basic_type_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def register_default_types
register_type 0, 'inet', PG::TextEncoder::Inet, PG::TextDecoder::Inet
alias_type 0, 'cidr', 'inet'

register_type 0, 'record', PG::TextEncoder::Record, PG::TextDecoder::Record


register_type 1, 'int2', PG::BinaryEncoder::Int2, PG::BinaryDecoder::Integer
Expand Down
10 changes: 10 additions & 0 deletions spec/pg/basic_type_map_for_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@
end
end

[0].each do |format|
it "should do format #{format} anonymous record type conversions" do
res = @conn.exec_params( "SELECT 6, ROW(123, 'str', true, null), 7
", [], format )
expect( res.getvalue(0,0) ).to eq( 6 )
expect( res.getvalue(0,1) ).to eq( ["123", "str", "t", nil] )
expect( res.getvalue(0,2) ).to eq( 7 )
end
end

[0].each do |format|
it "should do format #{format} inet type conversions" do
vals = [
Expand Down

0 comments on commit beafa09

Please sign in to comment.