Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PG::RecordCoder for en/decoding of Composite Types #36

Merged
merged 7 commits into from
Oct 9, 2019

Conversation

larskanis
Copy link
Collaborator

@larskanis larskanis commented Apr 6, 2019

This implements proper encoder and decoder for Composite Types as described in https://www.postgresql.org/docs/11/rowtypes.html and as requested in https://bitbucket.org/ged/ruby-pg/issues/258

This adds the following classes:

  • PG::RecordCoder < PG::Coder
  • PG::RecordEncoder < PG::RecordCoder
  • PG::RecordDecoder < PG::RecordCoder
  • PG::TextEncoder::Record < PG::RecordEncoder
  • PG::TextDecoder::Record < PG::RecordDecoder

I first took PG::RowCoder as class name, due to the ROW(...) expression provided by PostgreSQL. However this is changed in the second commit, since "Row" is too generic in my opinion and could lead to confusion with CopyRow. So I think "Record" expresses this type of data best.

Unfortunately the names PG::CompositeCoder, PG::CompositeDecoder and PG::CompositeEncoderare already in use (since pg-0.18.0). They should have been named PG::ArrayCoder instead, but now it's probably too late to change them, since they have been released years ago. Actually I doubt that PG::CompositeCoder etc. are in use in any external code, but I don't want to break the API for the sake of consistency.

@crashtech
Copy link

I'm looking forward to this feature!

@larskanis larskanis force-pushed the row-coder branch 2 times, most recently from 602e570 to 44578ba Compare April 20, 2019 21:50
@larskanis larskanis force-pushed the row-coder branch 2 times, most recently from 07d353a to b758fa2 Compare October 4, 2019 15:47
This implements proper encoder and decoder for Composite Types
as described in https://www.postgresql.org/docs/11/rowtypes.html
and as requested in https://bitbucket.org/ged/ruby-pg/issues/258

This adds the following classes:
* PG::RowCoder < PG::Coder
* PG::RowEncoder < PG::RowCoder
* PG::RowDecoder < PG::RowCoder
* PG::TextEncoder::Row < PG::RowEncoder
* PG::TextDecoder::Row < PG::RowDecoder

Fixes ged#258
I think this makes the purpose of the en/decoder more clear and distances from CopyRow coders.

So this renames the classes to these:
* PG::RecordCoder < PG::Coder
* PG::RecordEncoder < PG::RecordCoder
* PG::RecordDecoder < PG::RecordCoder
* PG::TextEncoder::Record < PG::RecordEncoder
* PG::TextDecoder::Record < PG::RecordDecoder
... and add documentation to record encoder and decoder.
@larskanis larskanis changed the title WIP: Add PG::RowCoder for en/decoding of Composite Types Add PG::RecordCoder for en/decoding of Composite Types Oct 4, 2019
@larskanis
Copy link
Collaborator Author

@ged After almost 3 years of development this is now ready to be reviewed and merged.

I accidentally already pushed this patches into the bitbucket default branch and don't know how to remove it from there. If this PR is OK to merge I'll sync github and bitbucket again.

Copy link
Owner

@ged ged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't wait to try this out. I have a project coming up that I'm planning on using this for.

@ged ged mentioned this pull request Oct 8, 2019
@larskanis larskanis merged commit 8fa4377 into ged:master Oct 9, 2019
@larskanis larskanis deleted the row-coder branch October 9, 2019 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants