Skip to content

Public API for managing type handling/mapping #1475

Closed

Description

@roji

The type handler API is currently purely internal in Npgsql - it's not possible for users to provide their own handlers, either for custom types not yet supported by Npgsql or to override the default behavior.

Once the type handler API is deemed stable enough, provide an API to allow users to do their own type mapping/handling.

Scenarios where this is needed:

Activity

  1. added this to the milestone on Mar 4, 2017
  2. self-assigned this
    on Mar 4, 2017
  3. johnberzy-bazinga commented on May 19, 2017

    @johnberzy-bazinga

    Following up from the issue #1550 :

    In my specific case, we're using a fork Agensgraph that requires the addition of Vertex, Edge, GraphId and Path types. Since this is not a very popular fork, it does not make much sense to include these type handlers directly in the core NpgSql repository. Falling back to the text-based protocol is not an option for us.

    Thanks,
    John

  4. roji commented on May 23, 2017

    @roji
    MemberAuthor

    Another scenario: some users want to do their own timezone conversion (e.g. #1469 (comment)), this could be done by overriding the default date/time handlers.

    In a similar way, this would allow users to get Nodatime types (#546).

  5. roji commented on May 23, 2017

    @roji
    MemberAuthor

    Possible complication to consider - the EF Core provider dynamically loads Npgsql's type mappings for its own type mapping... Think about the implications.

  6. roji commented on Jun 16, 2017

    @roji
    MemberAuthor

    Another nice scenario - json/jsonb handlers which add the possibility to read/write directly to objects, performing serialization/deserialization with NewtonSoft.JSON. This adds another layer of complexity, since a type handler currently can't support reading an arbitrary type - it must specify which types are supported by implementing ISimpleTypeHandler<T> etc. But this would be really nice.

  7. roji commented on Jul 3, 2017

    @roji
    MemberAuthor

    This was done in 4a503c7 (and some in c3dd084).

    Need to document.

  8. johnberzy-bazinga commented on Jul 3, 2017

    @johnberzy-bazinga

    This looks great! Thanks @roji!

  9. roji commented on Jul 3, 2017

    @roji
    MemberAuthor

    For anyone interested, until there's some proper documentation take a look at the Json.NET plugin (src/Npgsql.Json.NET). It shows what a basic type handler can do. A Nodatime plugin is also in the works.

    I'd love to get feedback on the API etc. There may definitely be some things - I've tried not to expose too many internal APIs, at least not until we know they are needed.

  10. changed the title [-]Open up type handling/mapping[/-] [+]Public API for managing type handling/mapping[/+] on Jul 3, 2017
  11. roji commented on Jul 3, 2017

    @roji
    MemberAuthor

    And one last word of warning :) This is a very new extensibility API, and although I spent some time on making sure it's good it may definitely change a little as shortcomings and extra needs are discovered. If you actually develop an external plugin be prepared that although public, this API may definitely change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions