Replies: 1 comment 1 reply
-
|
Thanks for writing this proposal. I wonder how common this pattern is. At least in my experience you often have one insertable type for your tables. I would guess that this is the case for most other users as well. Given that it's hard to say this additional complexity is something that we want to maintain in diesel.. On the other hand that seems like something that could be reasonably done by a macro outside of diesel, so maybe it's a better approach here to start with such a macro outside of diesel and if it turns out to be a common pattern we still can pull it back? |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Backend
PostgreSQL, MySQL, SQLite
What do you want to add to diesel?
It would be awesome to be able to derive
Insertablefor struct enums. For example:Of course, you just could do this:
This is a fair amount of boilerplate, especially as the numbers of fields and variants increase. It also means polluting the codebase with new structs (
GenericMenuItem,Sandwich, andSaladcould all be eliminated).Implementation notes
On a high level, I think for enums like this:
we could take the union of all the fields, and then the resulting values tuple would be equivalent to the output of
GenericMenuItem::valuesabove.I doubt enums like the below could be supported with a derive, since the derive wouldn't have access to the underlying fields of
SaladandSandwichbut supporting the first type would be a great improvement.
Additional details
No response
Checklist
Beta Was this translation helpful? Give feedback.
All reactions