Ziyang Hu 1 year ago
parent cd3c3bd5a7
commit 55c27e4396

@ -135,7 +135,7 @@ limit_option = {":limit" ~ expr}
offset_option = {":offset" ~ expr}
sort_option = {(":sort" | ":order") ~ (sort_arg ~ ",")* ~ sort_arg }
relation_option = {relation_op ~ (compound_ident | underscore_ident) ~ table_schema?}
relation_op = _{relation_create | relation_replace | relation_put | relation_update | relation_rm | relation_ensure | relation_ensure_not}
relation_op = _{relation_create | relation_replace | relation_put | relation_update | relation_rm | relation_ensure_not | relation_ensure }
relation_create = {":create"}
relation_replace = {":replace"}
relation_put = {":put"}

@ -58,6 +58,7 @@ fn test_limit_offset() {
.into_json();
assert_eq!(res["rows"], json!([]));
}
#[test]
fn test_normal_aggr_empty() {
let db = new_cozo_mem().unwrap();
@ -67,6 +68,7 @@ fn test_normal_aggr_empty() {
.rows;
assert_eq!(res, vec![vec![DataValue::from(0)]]);
}
#[test]
fn test_meet_aggr_empty() {
let db = new_cozo_mem().unwrap();
@ -82,6 +84,7 @@ fn test_meet_aggr_empty() {
.rows;
assert_eq!(res, vec![vec![DataValue::Null, DataValue::from(0)]]);
}
#[test]
fn test_layers() {
let _ = env_logger::builder().is_test(true).try_init();
@ -101,6 +104,7 @@ fn test_layers() {
.rows;
assert_eq!(res[0][0], DataValue::from(21.))
}
#[test]
fn test_conditions() {
let _ = env_logger::builder().is_test(true).try_init();
@ -132,6 +136,7 @@ fn test_conditions() {
.rows;
assert_eq!(res[0][0], DataValue::from(1.1))
}
#[test]
fn test_classical() {
let _ = env_logger::builder().is_test(true).try_init();
@ -183,19 +188,19 @@ fn rm_does_not_need_all_keys() {
assert!(db
.run_script(
"?[uid, mood] <- [[1, 2]] :put status {uid => mood}",
Default::default()
Default::default(),
)
.is_ok());
assert!(db
.run_script(
"?[uid, mood] <- [[2]] :put status {uid}",
Default::default()
Default::default(),
)
.is_err());
assert!(db
.run_script(
"?[uid, mood] <- [[3, 2]] :rm status {uid => mood}",
Default::default()
Default::default(),
)
.is_ok());
assert!(db
@ -1160,6 +1165,18 @@ fn multi_index_vec() {
}
}
#[test]
fn ensure_not() {
let db = DbInstance::new("mem", "", "").unwrap();
db.run_script(r"
%ignore_error { :create id_alloc{id: Int => next_id: Int, last_id: Int}}
%ignore_error {
?[id, next_id, last_id] <- [[0, 1, 1000]];
:ensure_not id_alloc{id => next_id, last_id}
}
", Default::default()).unwrap();
}
#[test]
fn parser_corner_case() {
let db = DbInstance::new("mem", "", "").unwrap();

Loading…
Cancel
Save