Ensure UPDATE table:id MERGE {} works correctly ()

Co-authored-by: Rushmore Mushambi <rushmore@surrealdb.com>
This commit is contained in:
Tobie Morgan Hitchcock 2024-05-15 11:45:53 +01:00 committed by GitHub
parent 75f48af276
commit 8dfdf3dd88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions
core/src/sql/value

View file

@ -52,8 +52,10 @@ impl Value {
false => vec![prev],
}
}
// Process everything else
_ => vec![prev],
// Process every other path
_ if !prev.is_empty() => vec![prev],
// Nothing to do
_ => vec![],
}
}
}
@ -64,6 +66,13 @@ mod tests {
use super::*;
use crate::syn::Parse;
#[test]
fn every_empty() {
let val = Value::parse("{}");
let res: Vec<Idiom> = vec![];
assert_eq!(res, val.every(None, false, false));
}
#[test]
fn every_with_empty_objects_arrays() {
let val = Value::parse("{ test: {}, status: false, something: {age: 45}, tags: []}");

View file

@ -30,6 +30,7 @@ mod tests {
async fn merge_none() {
let mut res = Value::parse(
"{
test: true,
name: {
first: 'Tobie',
last: 'Morgan Hitchcock',
@ -46,10 +47,38 @@ mod tests {
}
}
#[tokio::test]
async fn merge_empty() {
let mut res = Value::parse(
"{
test: true,
name: {
first: 'Tobie',
last: 'Morgan Hitchcock',
initials: 'TMH',
},
}",
);
let val = Value::parse(
"{
test: true,
name: {
first: 'Tobie',
last: 'Morgan Hitchcock',
initials: 'TMH',
},
}",
);
let mrg = Value::Object(Default::default());
res.merge(mrg).unwrap();
assert_eq!(res, val);
}
#[tokio::test]
async fn merge_basic() {
let mut res = Value::parse(
"{
test: true,
name: {
first: 'Tobie',
last: 'Morgan Hitchcock',
@ -68,6 +97,7 @@ mod tests {
);
let val = Value::parse(
"{
test: true,
name: {
title: 'Mr',
first: 'Tobie',