Fix bug with object array-indexed string field names appearing with quotation marks (#4657)

This commit is contained in:
Tobie Morgan Hitchcock 2024-09-02 10:13:47 +01:00 committed by GitHub
parent cefb95df28
commit 7588c7e31a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 1 deletions

View file

@ -65,7 +65,7 @@ impl Value {
_ => { _ => {
let mut obj = Value::base(); let mut obj = Value::base();
stk.run(|stk| obj.set(stk, ctx, opt, path.next(), val)).await?; stk.run(|stk| obj.set(stk, ctx, opt, path.next(), val)).await?;
v.insert(f.to_string(), obj); v.insert(f.to_raw(), obj);
Ok(()) Ok(())
} }
}, },

View file

@ -282,6 +282,46 @@ async fn update_with_return_clause() -> Result<(), Error> {
Ok(()) Ok(())
} }
#[tokio::test]
async fn update_with_object_array_string_field_names() -> Result<(), Error> {
let sql = "
UPSERT person:one SET field.key = 'value';
UPSERT person:two SET field['key'] = 'value';
";
let dbs = new_ds().await?;
let ses = Session::owner().with_ns("test").with_db("test");
let res = &mut dbs.execute(sql, &ses, None).await?;
assert_eq!(res.len(), 2);
//
let tmp = res.remove(0).result?;
let val = Value::parse(
"[
{
field: {
key: 'value'
},
id: person:one
}
]",
);
assert_eq!(tmp, val);
//
let tmp = res.remove(0).result?;
let val = Value::parse(
"[
{
field: {
key: 'value'
},
id: person:two
}
]",
);
assert_eq!(tmp, val);
//
Ok(())
}
// //
// Permissions // Permissions
// //