2023-01-06 10:26:25 +00:00
|
|
|
mod parse;
|
|
|
|
use surrealdb::dbs::Session;
|
|
|
|
use surrealdb::err::Error;
|
|
|
|
use surrealdb::kvs::Datastore;
|
|
|
|
use surrealdb::sql::Value;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn compare_empty() -> Result<(), Error> {
|
|
|
|
let sql = r#"
|
|
|
|
RETURN NONE = NONE;
|
|
|
|
RETURN NULL = NULL;
|
|
|
|
RETURN NONE = NULL;
|
|
|
|
RETURN [] = [];
|
|
|
|
RETURN {} = {};
|
|
|
|
RETURN [] = {};
|
|
|
|
RETURN 0 = 0;
|
|
|
|
RETURN 0 = 0.0;
|
|
|
|
RETURN 0 = 0.1;
|
|
|
|
"#;
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
2023-07-05 21:26:13 +00:00
|
|
|
let res = &mut dbs.execute(sql, &ses, None).await?;
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(res.len(), 9);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(false);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(false);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(true);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
2023-04-29 15:58:22 +00:00
|
|
|
let val = Value::Bool(false);
|
2023-01-06 10:26:25 +00:00
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|