diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index aa5d08b2..948eae77 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -2780,6 +2780,7 @@ pub fn start(i: &str) -> IResult<&str, Value> { /// Used in CREATE, UPDATE, and DELETE clauses pub fn what(i: &str) -> IResult<&str, Value> { alt(( + map(idiom::multi, Value::from), map(function, Value::from), map(subquery, Value::from), map(constant, Value::from), diff --git a/lib/tests/delete.rs b/lib/tests/delete.rs new file mode 100644 index 00000000..d667f757 --- /dev/null +++ b/lib/tests/delete.rs @@ -0,0 +1,26 @@ +mod parse; +use parse::Parse; + +use surrealdb::dbs::Session; +use surrealdb::err::Error; +use surrealdb::kvs::Datastore; +use surrealdb::sql::Value; + +#[tokio::test] +async fn delete_with_idiom_value() -> Result<(), Error> { + let sql = " + let $person = RETURN CREATE person:bob; + DELETE $person.id; + "; + let dbs = Datastore::new("memory").await?; + let ses = Session::for_kv().with_ns("test").with_db("test"); + let res = &mut dbs.execute(sql, &ses, None).await?; + assert_eq!(res.len(), 2); + // + let _ = res.remove(0).result?; + // + let tmp = res.remove(0).result?; + let val = Value::parse("[]"); + assert_eq!(tmp, val); + Ok(()) +}