Doobe Psql module integration
See original GitHub issueVery similar issue to #227 . If you use DoobieEnum
with postgres enum types, you get errors like:
"org.postgresql.util.PSQLException: ERROR: column "shirt" is of type shirtsize but expression is of type character varying"
In order to work with postgres enums in doobie, you need to provide the name of the type you have created. E.g. if you have CREATE TYPE shirt_size AS ENUM ('small', 'medium', 'large');
, then you need to create a doobie meta
instance like so: implicit val meta: Meta[ShirtSize] = pgEnumString("shirt_size", withName(_), _.entryName)
.
If enumeratum-doobie
was going to include such an instance for the user, you would probably have to add def enumTypeName: String
as an implementation detail for the user in DoobieEnum
. Maybe instead a new mixin called DoobieStrictEnum
could be added that provides this functionality? Happy to work on a PR for this and add a section to the readme, if there is interest for this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Actually I came to the same realization yesterday when I started having a closer look at this 😁
I don’t think (2) is that worthwhile unless there was substantially more that could be pulled out into its own package - its really only 2 lines.
I think (1) is fine. I’ll submit a PR to update the readme.
At this point, the issue is to add a section to the readme to document the Doobie + Psql mix in. There are no plans to add a Psql-specific integration, if that’s your question.