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

Customizable serialization of PostgresType #965

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Commits on Mar 8, 2023

  1. Problem: CBOR is not the most universal answer to everything

    However, all `Serialize/Deserialize` PostgresTypes are forced to use it
    with the blanket implementation of `IntoDatum`/`FromDatum`
    
    Solution: extract a `Serializer` trait to abstract this away
    
    By default, it uses CBOR and encodes it into a Varlena, replicating
    existing behavior.
    
    However, this gives a good amount of flexibility to end-user to
    determine their encoding needs.
    
    I've also removed JSON-encoding/decoding functions from varlena module,
    as they don't seem to be used anywhere.
    yrashk committed Mar 8, 2023
    Configuration menu
    Copy the full SHA
    44ca08b View commit details
    Browse the repository at this point in the history
  2. Problem: missing documentation for pgx::ddatum::Serializer

    Makes it unclear whether it's advisable to use it externally.
    
    Solution: document it
    yrashk committed Mar 8, 2023
    Configuration menu
    Copy the full SHA
    38120f1 View commit details
    Browse the repository at this point in the history
  3. Problem: pgx::datum::Serializer trait scope

    It takes care of both serialization and deserialization. However, some
    types can potentially be only deserialized, or serialized. Besides, the
    naming of the trait itself showed that it is not a perfect match.
    
    Solution: split it into Serializer and Deserializer, respectively
    yrashk committed Mar 8, 2023
    Configuration menu
    Copy the full SHA
    cd26d68 View commit details
    Browse the repository at this point in the history
  4. Problem: custom_serializer test is not checking serialization

    For all we know, it may still be using CBOR.
    
    Solution: ensure we're getting our custom serialization
    yrashk committed Mar 8, 2023
    Configuration menu
    Copy the full SHA
    9153f8f View commit details
    Browse the repository at this point in the history