-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Feature Request] Enum Support #166
Comments
This is not strictly helpful to you since you already stumbled upon how to add enum support, but for others: There now is norm documentation that details how to add support for whatever data-type you have, including enums. I'm conflicted on providing a default when this feels like a decision the user might want to specify themselves (not that my opinion matters, I merely wanted to voice it). Luckily, as you noted, adding default enum support isn't really difficult, literally just defining these 3 procs once for sqlite and once for postgres and then writing some test-cases for it (which should include a test-case where the default procs get overwritten by user-defined procs for a specific enum, just to make sure that works). |
I agree with the previous comment. Summary:
|
Was implemented in lowdb as part of PhilippMDoerner/lowdb#8 , kudos to ire4ever for doing pretty much all of the work there. Did show me that I should be going over the test-suite there though. So I just need to release a new lowdb version and norm needs to update its lowdb dependency and we have it here. |
You've already indirectly talked about enum support in
#34 (comment)
Enums feel like a rather important thing in nim to me, so I think it would great to support it out of the box.
Since Postgres has an enumtype it should be kinda straight forward.
Regarding your question how to handle enums in sqlite:
I have this in my project atm, which encodes enums as strings and parses them back using
std/strutils.parseEnum
I imagine this could be rather costly for huge databases, so I don't know if it's a great solution.
However the benefit is, that the meaning of the value is preserved in the database.
The alternative would be to encode the enum as ints, obviously. Probably that is the better default choice.
The best way would be, to enable norm users to choose I guess.
Thanks for all the work put into norm. It's great!
The text was updated successfully, but these errors were encountered: