Skip to content

Add codec for Postgres enumerated types #244

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

Closed
My- opened this issue Feb 8, 2020 · 2 comments
Closed

Add codec for Postgres enumerated types #244

My- opened this issue Feb 8, 2020 · 2 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@My-
Copy link

My- commented Feb 8, 2020

Feature Request

Looks like enums are not supported.

Is your feature request related to a problem? Please describe

Maybe I missing something, or doing something wrong but I can't make Postgres enum type work (query with SELECT, INSERT).

Describe the solution you'd like

Possibility to map directly to Java enum type to Postgres enum.

Describe alternatives you've considered

An alternative could be to get enum value as a string.

Teachability, Documentation, Adoption, Migration Strategy

@mp911de
Copy link
Collaborator

mp911de commented Feb 8, 2020

We decided to not support Java native enums within the driver as enums are a user-space feature regarding their mapping possibilities (string name, ordinal, Postgres type). You can register your own codec if you wish to do so with your specific mapping rules.

@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply status: duplicate A duplicate of another issue labels Feb 8, 2020
@mp911de mp911de closed this as completed Feb 8, 2020
@mp911de mp911de added type: enhancement A general enhancement and removed status: declined A suggestion or change that we don't feel we should currently apply status: duplicate A duplicate of another issue labels May 29, 2020
@mp911de
Copy link
Collaborator

mp911de commented May 29, 2020

Reopening this issue. The assumption back then was to make enums work with either the VARCHAR or a numeric codec and that's what my previous comment was about.

We can make Postgres enumerated types work by providing a EnumCodec that takes an OID and the Java enum type so we can map enumerated values in both types. From a particular Java type we can derive the Postgres type OID. While reading, we have a reference to a Java enum and can materialize a value.

@mp911de mp911de reopened this May 29, 2020
@mp911de mp911de changed the title Postgres enum Add codec for Postgres enumerated types May 29, 2020
mp911de added a commit that referenced this issue May 29, 2020
We now provide a EnumCodec to map Java types to Postgres enumerated types.

[closes #244]
mp911de added a commit that referenced this issue Jun 16, 2020
Add support for Postgres enumerated types

[#244][#284]
mp911de added a commit that referenced this issue Jun 16, 2020
Add support for Postgres enumerated types

[#244][#284]
@mp911de mp911de added this to the 0.8.4.RELEASE milestone Jun 16, 2020
@mp911de mp911de closed this as completed Jun 16, 2020
mp911de added a commit that referenced this issue Jun 16, 2020
Add support for Postgres enumerated types

[#244][#284]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants