Support native enums newtypes #4368
SamuelMarks
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
Hi, I am trying to work with native PG enum too. And I don't get the examples. it seems these constructs try to translate Rust enum type to PG integer. What is strum_macros in your example ? |
Beta Was this translation helpful? Give feedback.
3 replies
-
There is native support for enum types in diesel. We just expect you to provide your own rust enums (like we also do for other types). You obviously need to implement the corresponding type mappings, so in this case |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here is my
up.sql
(simplified without duplicate_object exception handling):Diesel generates this:
Trying to get it to work, added
Debug, PartialEq
, got most errors to disappear, but then getting errors like:Found this example from 2018 #1783 (comment) - so can probably hack around there until it works (mapping to a real newtype rather than
smallint
). Something like:Any chance we can have native enum support in diesel?
FWIW: SQLalchemy in Python has gotten this to work - https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.Enum
Thanks for your consideration
Beta Was this translation helpful? Give feedback.
All reactions