-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add #[derive(ormlite::Enum)]
Procedural Macro
#59
Conversation
ok! how is this looking @kurtbuilds ? |
bump! |
let me get the master tests fixed this wekeend, then i'll tackle this. busy time personally as i'm moving apartments, so feel free to bump again if i don't get to it. |
sound good! no rush dude and congrats on the move |
bump! |
…import FromStr when deriving ormlite::Enum
should i keep bumping? @kurtbuilds |
@kurtbuilds the builds are going to continue to fail until that test is addressed. i think it started happening when that builder-struct-add-derive pr was merged but i might be wrong! should i take a stab at addressing it? |
Thank you for the pings! I'm fixing the test now, it's from an experimental feature I added around a month ago. I'm actually reverting that feature b/c it didn't behave as desired, and then I'll merge this in. |
amazing! thanks @kurtbuilds once thats addressed my other PRs should pass too |
publishing as 0.22.8. Thank you again! |
This pull request introduces a new procedural macro,
#[derive(ormlite::Enum)]
, to simplify the process of creating enums compatible withormlite
andSQLx
. This macro automates the implementation of various traits for enums, such as:std::fmt::Display
std::str::FromStr
std::convert::TryFrom
sqlx::Encode
sqlx::Decode
sqlx::Type
By deriving
ormlite::Enum
, developers can focus on defining their enums while ensuring they are ready to use withormlite
and SQLx without boilerplate code.Example Usage
Before this feature, developers needed to manually implement traits for each enum:
With
#[derive(ormlite::Enum)]
, the code becomes:Features
Display
for string representationsFromStr
for parsing strings into enum variantsEncode
,Decode
,Type
) for seamless database integrationTechnical Details
Macro Implementation:
proc-macro
crate with dependencies onsyn
,quote
, andproc-macro2
.Impact
How to Use
#[derive(ormlite::Enum)]
:ormlite::Model
s:Next Steps
ormlite
to include the new macro.Acknowledgments
Special thanks to everyone involved in designing and refining this crate! It's beautifully simple. 🎉
Closes #37