surrealpatch/lib/tests/delete.rs

27 lines
626 B
Rust
Raw Normal View History

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