-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: added chrono support as optional feature and extend bindable! #10
Conversation
replaced $t:ident with $t:ty that way it matches any Rust type including DateTime<Utc>
This is awesome. I will look at it by the end of next week. If I forget by the end of next week, feel free to ping me. |
@kaiserbh wow, this is very high quality, concise PR. Thanks a lot!!! I am planning to merge it and release |
Released in @kaiserbh can you give me an example of how you use the type parameter with the new bindable? |
Thank you I updated my crate now using it directly from crates.io, no issues so far. @jeremychone Also this is how I am using it personally. cargo.toml
sqlb = { version = "0.3.4", features = ["chrono-support"] } #[derive(sqlb::Fields, Default, Clone, Deserialize)]
pub struct SubscriptionPatch {
pub client_id: Option<i32>,
pub plan_id: Option<i32>,
pub subscription_start: Option<chrono::DateTime<chrono::Utc>>,
pub subscription_end: Option<chrono::DateTime<chrono::Utc>>,
pub status: Option<SubscriptionStatus>,
}
#[derive(sqlx::Type, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[sqlx(type_name = "subscription_status")]
pub enum SubscriptionStatus {
Active,
Expired,
Cancelled,
}
sqlb::bindable!(SubscriptionStatus); |
@kaiserbh super cool! thanks! |
@kaiserbh hum, but this code (or simplified one still work with the old bindable! macro). Trying to find a code that would not. |
Hmm for some reason when I added |
@kaiserbh ho yes, you are right. My bad. I did not replicate this part. Trying to do my own custom generic type to show the new feature. Anyway, do not worry about it, I will find a way. Uou actually fixed a "bug" I had, it should have been |
No worries, thanks for making the project. |
Cool, find a way to reproduce the error of // Note: Just a compile check.
#[test]
pub fn test_bindable_generic() -> Result<()> {
#[derive(Debug, Clone, sqlx::Type)]
#[sqlx(transparent)]
pub struct ClientRef<T>(T);
sqlb::bindable!(ClientRef<String>);
Ok(())
} Works perfectly with the Just adding it as a unit test main branch (currently |
Description:
Enhances the bindable! macro to handle Rust types that require type parameters. This is a significant improvement because it allows us to use the bindable! macro with complex types that have parameters, like chrono::DateTimechrono::Utc.
Changes:
Tests
I have run
cargo test
and everything seem to be working fine and passed.Note: I am new to rust so if there is anything I did wrong or can be improved do let me know.