Fix bug with object array-indexed string field names appearing with quotation marks (#4657)
This commit is contained in:
parent
cefb95df28
commit
7588c7e31a
2 changed files with 41 additions and 1 deletions
|
@ -65,7 +65,7 @@ impl Value {
|
|||
_ => {
|
||||
let mut obj = Value::base();
|
||||
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(())
|
||||
}
|
||||
},
|
||||
|
|
|
@ -282,6 +282,46 @@ async fn update_with_return_clause() -> Result<(), Error> {
|
|||
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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue