Make what
parser to parse idioms as well (#2243)
This commit is contained in:
parent
7f4d2e4849
commit
a2ef2d83df
2 changed files with 27 additions and 0 deletions
|
@ -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),
|
||||
|
|
26
lib/tests/delete.rs
Normal file
26
lib/tests/delete.rs
Normal 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(())
|
||||
}
|
Loading…
Reference in a new issue