edgedb-rust icon indicating copy to clipboard operation
edgedb-rust copied to clipboard

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

Open XAMPPRocky opened this issue 1 year ago • 0 comments

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):

  • OS:
  • EdgeDB version: 4.0
  • Rust compiler version: 1.73.0
  • Cargo version: 1.73.0
  • EdgeDB Rust versions: a109491

XAMPPRocky avatar Nov 02 '23 16:11 XAMPPRocky