nodecosmos / charybdis

Rust ORM for ScyllaDB and Apache Cassandra
MIT License
108 stars 6 forks source link

How to use `Time` and `Duration`? #20

Closed Zk2u closed 3 months ago

Zk2u commented 3 months ago

Hi, sorry I know I'm opening a lot of issues. Does charybdis support the use of the Time and Duration scylla types? If so how do I use them?

I know Time is a chrono::DateTime<Utc> even though i think it should be the NaiveTime type that the scylla crate uses because Time only specifies a time in a day, not a date.

Duration is just a string and not sure how to work with it

GoranBrkuljan commented 3 months ago

Hi, sorry I know I'm opening a lot of issues.

Np, happy to assist.

Duration is not supported yet. I added it there for testing migrations, but forgot to remove it before we add support for it. We don't use native CqlDuration as it doesn't have serde & default traits implemented that we want all of our types to have. We could fix this by introducing our wrapper tuple struct (newtype pattern) that will implement required traits pub struct Duration(value::CqlDuration). We did same thing for Counter.

For Time your are right, will be fixed.

I will add support for both in next release.

Zk2u commented 3 months ago

Thanks @GoranBrkuljan. We're building something at the moment quickly (releasing by end of month) that requires using both Duration and Time - do you have a rough idea of when you could get this out?

GoranBrkuljan commented 3 months ago

@617a7aa Later today, this as well as find_by_global_indexes functions.

Zk2u commented 3 months ago

Thank you so much 🙏

GoranBrkuljan commented 3 months ago

updated with release: https://github.com/nodecosmos/charybdis/releases/tag/v0.4.17

GoranBrkuljan commented 3 months ago

@617a7aa Note that in future version all of these functions will be updated to take references instead of owned values.

Zk2u commented 3 months ago

Thank you very much and no worries, that's a good idea!