edgedb-rust
edgedb-rust copied to clipboard
Cannot use `Duration` in queries
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):
- OS: Ubuntu on WSL
- EdgeDB version: EdgeDB 3.4+301ba34 (repl 3.5.0+907ff37)
- EdgeDB CLI version: EdgeDB CLI 3.5.0+907ff37
- Rust compiler version: rustc 1.72.1 (d5c2e9c34 2023-09-13)
- Cargo version: cargo 1.72.1 (103a7ff2e 2023-08-15)
- EdgeDB Rust versions:
- edgedb-protocol: 0.6.0
- edgedb-tokio: 0.5.0
Additional context N/A
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?
Rust Client won't support interpolation through client.
Try something like this.
format!("select <duration>"{}", "300h")