|
|
|
@ -32,29 +32,23 @@ use {
|
|
|
|
|
mod alter_space {
|
|
|
|
|
use {
|
|
|
|
|
super::*,
|
|
|
|
|
crate::engine::{
|
|
|
|
|
data::lit::Lit,
|
|
|
|
|
ql::{ast::parse_ast_node_full, ddl::alt::AlterSpace},
|
|
|
|
|
},
|
|
|
|
|
crate::engine::{data::lit::Lit, ql::ddl::alt::AlterSpace},
|
|
|
|
|
};
|
|
|
|
|
#[test]
|
|
|
|
|
fn alter_space_mini() {
|
|
|
|
|
let tok = lex_insecure(b"alter model mymodel with {}").unwrap();
|
|
|
|
|
let r = parse_ast_node_full::<AlterSpace>(&tok[2..]).unwrap();
|
|
|
|
|
fullparse_verify_substmt("alter model mymodel with {}", |r: AlterSpace| {
|
|
|
|
|
assert_eq!(r, AlterSpace::new(Ident::from("mymodel"), null_dict! {}));
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn alter_space() {
|
|
|
|
|
let tok = lex_insecure(
|
|
|
|
|
br#"
|
|
|
|
|
fullparse_verify_substmt(
|
|
|
|
|
r#"
|
|
|
|
|
alter model mymodel with {
|
|
|
|
|
max_entry: 1000,
|
|
|
|
|
driver: "ts-0.8"
|
|
|
|
|
}
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let r = parse_ast_node_full::<AlterSpace>(&tok[2..]).unwrap();
|
|
|
|
|
}"#,
|
|
|
|
|
|r: AlterSpace| {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
r,
|
|
|
|
|
AlterSpace::new(
|
|
|
|
@ -65,6 +59,8 @@ mod alter_space {
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mod tymeta {
|
|
|
|
@ -378,32 +374,13 @@ mod fields {
|
|
|
|
|
}
|
|
|
|
|
mod schemas {
|
|
|
|
|
use super::*;
|
|
|
|
|
use crate::engine::ql::{
|
|
|
|
|
ast::parse_ast_node_full_with_space,
|
|
|
|
|
ddl::{
|
|
|
|
|
use crate::engine::ql::ddl::{
|
|
|
|
|
crt::CreateModel,
|
|
|
|
|
syn::{FieldSpec, LayerSpec},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema_mini() {
|
|
|
|
|
let tok = lex_insecure(
|
|
|
|
|
b"
|
|
|
|
|
create model mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary
|
|
|
|
|
)
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let tok = &tok[2..];
|
|
|
|
|
|
|
|
|
|
// parse model
|
|
|
|
|
let model = parse_ast_node_full_with_space::<CreateModel>(tok, "apps").unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
model,
|
|
|
|
|
CreateModel::new(
|
|
|
|
|
let mut ret = CreateModel::new(
|
|
|
|
|
("apps", "mymodel").into(),
|
|
|
|
|
vec![
|
|
|
|
|
FieldSpec::new(
|
|
|
|
@ -417,32 +394,32 @@ mod schemas {
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
null_dict! {}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
null_dict! {},
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"create model mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary
|
|
|
|
|
)",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(r, ret),
|
|
|
|
|
);
|
|
|
|
|
ret.if_not_exists = true;
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"create model if not exists mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary
|
|
|
|
|
)",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(r, ret),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema() {
|
|
|
|
|
let tok = lex_insecure(
|
|
|
|
|
b"
|
|
|
|
|
create model mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary,
|
|
|
|
|
null profile_pic: binary
|
|
|
|
|
)
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let tok = &tok[2..];
|
|
|
|
|
|
|
|
|
|
// parse model
|
|
|
|
|
let model = parse_ast_node_full_with_space::<CreateModel>(tok, "apps").unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
model,
|
|
|
|
|
CreateModel::new(
|
|
|
|
|
let mut ret = CreateModel::new(
|
|
|
|
|
("apps", "mymodel").into(),
|
|
|
|
|
vec![
|
|
|
|
|
FieldSpec::new(
|
|
|
|
@ -462,56 +439,54 @@ mod schemas {
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
null_dict! {}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema_pro() {
|
|
|
|
|
let tok = lex_insecure(
|
|
|
|
|
b"
|
|
|
|
|
create model mymodel(
|
|
|
|
|
null_dict! {},
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"create model mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary,
|
|
|
|
|
null profile_pic: binary,
|
|
|
|
|
null notes: list {
|
|
|
|
|
type: string,
|
|
|
|
|
unique: true,
|
|
|
|
|
null profile_pic: binary
|
|
|
|
|
)",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(r, ret),
|
|
|
|
|
);
|
|
|
|
|
ret.if_not_exists = true;
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"create model if not exists mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary,
|
|
|
|
|
null profile_pic: binary
|
|
|
|
|
)",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(r, ret),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let tok = &tok[2..];
|
|
|
|
|
|
|
|
|
|
// parse model
|
|
|
|
|
let model = parse_ast_node_full_with_space::<CreateModel>(tok, "apps").unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
model,
|
|
|
|
|
CreateModel::new(
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema_pro() {
|
|
|
|
|
let mut ret = CreateModel::new(
|
|
|
|
|
("apps", "mymodel").into(),
|
|
|
|
|
vec![
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("username"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("string"), null_dict! {})],
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
true,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("password"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
false,
|
|
|
|
|
false
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("profile_pic"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("notes"),
|
|
|
|
@ -521,23 +496,20 @@ mod schemas {
|
|
|
|
|
Ident::from("list"),
|
|
|
|
|
null_dict! {
|
|
|
|
|
"unique" => Lit::new_bool(true)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
null_dict! {}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema_pro_max() {
|
|
|
|
|
let tok = lex_insecure(
|
|
|
|
|
b"
|
|
|
|
|
create model mymodel(
|
|
|
|
|
null_dict! {},
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
ret.if_not_exists = true;
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"
|
|
|
|
|
create model if not exists mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary,
|
|
|
|
|
null profile_pic: binary,
|
|
|
|
@ -545,42 +517,34 @@ mod schemas {
|
|
|
|
|
type: string,
|
|
|
|
|
unique: true,
|
|
|
|
|
}
|
|
|
|
|
) with {
|
|
|
|
|
env: {
|
|
|
|
|
free_user_limit: 100,
|
|
|
|
|
},
|
|
|
|
|
storage_driver: \"skyheap\"
|
|
|
|
|
}
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let tok = &tok[2..];
|
|
|
|
|
|
|
|
|
|
// parse model
|
|
|
|
|
let model = parse_ast_node_full_with_space::<CreateModel>(tok, "apps").unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
model,
|
|
|
|
|
CreateModel::new(
|
|
|
|
|
",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(ret, r),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn schema_pro_max() {
|
|
|
|
|
let mut ret = CreateModel::new(
|
|
|
|
|
("apps", "mymodel").into(),
|
|
|
|
|
vec![
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("username"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("string"), null_dict! {})],
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
true,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("password"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
false,
|
|
|
|
|
false
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("profile_pic"),
|
|
|
|
|
vec![LayerSpec::new(Ident::from("binary"), null_dict! {})],
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
FieldSpec::new(
|
|
|
|
|
Ident::from("notes"),
|
|
|
|
@ -590,21 +554,41 @@ mod schemas {
|
|
|
|
|
Ident::from("list"),
|
|
|
|
|
null_dict! {
|
|
|
|
|
"unique" => Lit::new_bool(true)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
null_dict! {
|
|
|
|
|
"env" => null_dict! {
|
|
|
|
|
"free_user_limit" => Lit::new_uint(100),
|
|
|
|
|
},
|
|
|
|
|
"storage_driver" => Lit::new_string("skyheap".into()),
|
|
|
|
|
},
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
ret.if_not_exists = true;
|
|
|
|
|
fullparse_verify_substmt_with_space(
|
|
|
|
|
"
|
|
|
|
|
create model if not exists mymodel(
|
|
|
|
|
primary username: string,
|
|
|
|
|
password: binary,
|
|
|
|
|
null profile_pic: binary,
|
|
|
|
|
null notes: list {
|
|
|
|
|
type: string,
|
|
|
|
|
unique: true,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
) with {
|
|
|
|
|
env: {
|
|
|
|
|
free_user_limit: 100,
|
|
|
|
|
},
|
|
|
|
|
storage_driver: \"skyheap\"
|
|
|
|
|
}",
|
|
|
|
|
"apps",
|
|
|
|
|
|r: CreateModel| assert_eq!(r, ret),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mod dict_field_syntax {
|
|
|
|
@ -1119,7 +1103,12 @@ mod ddl_other_query_tests {
|
|
|
|
|
let src = lex_insecure(br"drop space myspace").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full::<DropSpace>(&src[2..]).unwrap(),
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), false)
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), false, false)
|
|
|
|
|
);
|
|
|
|
|
let src = lex_insecure(br"drop space if exists myspace").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full::<DropSpace>(&src[2..]).unwrap(),
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), false, true)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
@ -1127,7 +1116,12 @@ mod ddl_other_query_tests {
|
|
|
|
|
let src = lex_insecure(br"drop space allow not empty myspace").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full::<DropSpace>(&src[2..]).unwrap(),
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), true)
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), true, false)
|
|
|
|
|
);
|
|
|
|
|
let src = lex_insecure(br"drop space if exists allow not empty myspace").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full::<DropSpace>(&src[2..]).unwrap(),
|
|
|
|
|
DropSpace::new(Ident::from("myspace"), true, true)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
@ -1135,7 +1129,12 @@ mod ddl_other_query_tests {
|
|
|
|
|
let src = lex_insecure(br"drop model mymodel").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full_with_space::<DropModel>(&src[2..], "apps").unwrap(),
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), false)
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), false, false)
|
|
|
|
|
);
|
|
|
|
|
let src = lex_insecure(br"drop model if exists mymodel").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full_with_space::<DropModel>(&src[2..], "apps").unwrap(),
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), false, true)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
@ -1143,7 +1142,12 @@ mod ddl_other_query_tests {
|
|
|
|
|
let src = lex_insecure(br"drop model allow not empty mymodel").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full_with_space::<DropModel>(&src[2..], "apps").unwrap(),
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), true)
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), true, false)
|
|
|
|
|
);
|
|
|
|
|
let src = lex_insecure(br"drop model if exists allow not empty mymodel").unwrap();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
parse_ast_node_full_with_space::<DropModel>(&src[2..], "apps").unwrap(),
|
|
|
|
|
DropModel::new(("apps", "mymodel").into(), true, true)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|