edgedb / edgedb-rust

The official Rust binding for EdgeDB
https://edgedb.com
Apache License 2.0
214 stars 26 forks source link

impl DecodeScalar for chrono::DateTime and chrono Naive types #274

Closed Dhghomon closed 1 year ago

Dhghomon commented 1 year ago

Looking at issue #263 and another discussion on Discord today, chrono::Datetime isn't usable with the EdgeDB client yet. It looks like the chrono interop module is already complete though and the only remaining item is to impl DecodeScalar for the type. There are already a few of these DecodeScalar impls for two other major Rust types (BigDecimal and BigInt) and they also have their own interop crates followed by impl DecodeScalar which returns the corresponding EdgeDB standard library types. e.g. here is the code for BigInt along with num_bigint::BigInt, giving the name uuid and typename:

impl DecodeScalar for BigInt { fn uuid() -> Uuid { codec::STD_BIGINT } fn typename() -> &'static str { "std::bigint" } }

[cfg(feature="num-bigint")]

impl DecodeScalar for num_bigint::BigInt { fn uuid() -> Uuid { codec::STD_BIGINT } fn typename() -> &'static str { "std::bigint" } }

So looks like Chrono's Datetime is already good to go as far as interop is concerned and is only lacking these lines of code to implement the trait. (Tried this locally as well and queries work once this is added)

Edit: the chrono_interop module also includes Chrono's naive types which correspond to EdgeDB's cal::local types, so have added these three as well.