edgedb / edgedb-rust

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

Cannot use `Duration` in queries #280

Open jquesada2016 opened 10 months ago

jquesada2016 commented 10 months ago

Describe the bug Trying to use edgedb_protocol::model::Duration, I get the following error:

error: Some(
            WrongType {
                unexpected: "BaseScalar(BaseScalarTypeDescriptor { id: BaseScalar(duration) })",
                expected: "cal::date_duration",
            },
        ),
        headers: {},
        fields: {
            (
                "capabilities",
                TypeId {
                    t: 192679019591847795036924881998469682383,
                },
            ): Any { .. },
        },
    },
)

Reproduction

let _ =
  edgedb.
    .query::<Duration, _>("select <duration>"300h", &())
    .expect("should not error");

Expected behavior Duration to decode correctly.

Versions (please complete the following information):

Additional context N/A

Dhghomon commented 10 months ago

I just gave the query you have here a try and it's working well for me with an output of [Duration { micros: 1080000000000 }]. Can you see any clues as to why it's expecting a DateDuration on your end instead of a regular Duration?

codeyash commented 9 months ago

Rust Client won't support interpolation through client.

Try something like this.

format!("select <duration>"{}", "300h")