2023-08-30 18:01:30 +00:00
|
|
|
mod helpers;
|
|
|
|
use helpers::new_ds;
|
2023-01-06 10:26:25 +00:00
|
|
|
use surrealdb::dbs::Session;
|
|
|
|
use surrealdb::err::Error;
|
|
|
|
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;
|
|
|
|
"#;
|
2023-08-30 18:01:30 +00:00
|
|
|
let dbs = new_ds().await?;
|
2023-07-29 18:47:25 +00:00
|
|
|
let ses = Session::owner().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(())
|
|
|
|
}
|