edgedb / edgedb-rust

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

fix(encode): compare shapes by sorted fields (credits to @hongquan) #299

Closed MrFoxPro closed 2 months ago

MrFoxPro commented 4 months ago

Problem:

use edgedb_protocol::{
   value::{EnumValue, Value as EValue},
};

let args = indexmap! {
   "me_num" => (Some(EValue::Int64(user.num)), Cd::One),
   "activities" => (Some(EValue::Array(vec![EValue::Enum(EnumValue::from("Freelancer"))])), Cd::AtMostOne)
};
let args = helpers::edge_object_from_pairs(m);

let q = "
   update User
   filter .num = <int64>$me_num
   set {
      activities := <optional array<Activity>>$activities ?? .activities,
   }
";
ctx.edb.execute(q, &args).await?;

Will fail with ClientEncodingError #298 Discord thread will full problem description: https://discord.com/channels/841451783728529451/1216718781846392852

I rewrote solution of @hongquan (#289) without reformatting, so changes are more readable. We can discuss here more elegant solution

MrFoxPro commented 2 months ago

Should be fixed by https://github.com/edgedb/edgedb-rust/pull/304