edgedb / edgedb-rust

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

`#[derive(Queryable)]` fields should not be position dependent. #285

Open XAMPPRocky opened 8 months ago

XAMPPRocky commented 8 months ago

Describe the bug Currently if your derived fields are not in the same order as your query's, you will run into "unexpected field foo expected bar" errors, which is not intuitive as most things in Rust do not require struct order.

Reproduction Include the code that is causing the error:

#[derive(Queryable)]
struct Foo {
 foo: String,
 bar: u64,
}

let foo = edgedb
        .query_single::<Foo, _>(
            "select Foo { bar, foo }",
            &(),
        )
        .await
        .unwrap();
called `Result::unwrap()` on an `Err` value: Error(Inner { code: 4278386176, messages: [], error: Some(WrongField { unexpected: "bar", expected: "foo" }), headers: {}, fields: {("capabilities", TypeId { t: 192899057483148890509852589200417735385 }): Any { .. }} })

Expected behavior I expect that the order the fields in the derive has no effect on the query's ability to decode, the above code should just work.

Versions (please complete the following information):