Make what parser to parse idioms as well (#2243)

This commit is contained in:
hchockarprasad 2023-07-15 21:56:36 +05:30 committed by GitHub
parent 7f4d2e4849
commit a2ef2d83df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -2780,6 +2780,7 @@ pub fn start(i: &str) -> IResult<&str, Value> {
/// Used in CREATE, UPDATE, and DELETE clauses /// Used in CREATE, UPDATE, and DELETE clauses
pub fn what(i: &str) -> IResult<&str, Value> { pub fn what(i: &str) -> IResult<&str, Value> {
alt(( alt((
map(idiom::multi, Value::from),
map(function, Value::from), map(function, Value::from),
map(subquery, Value::from), map(subquery, Value::from),
map(constant, Value::from), map(constant, Value::from),

26
lib/tests/delete.rs Normal file
View file

@ -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(())
}