SCHEMAFULL table should be TYPE NORMAL by default (#4558)
This commit is contained in:
parent
1f6e6fcfc5
commit
e25eca71d7
5 changed files with 20 additions and 11 deletions
|
@ -293,8 +293,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn pretty_define_query() {
|
fn pretty_define_query() {
|
||||||
let query = parse("DEFINE TABLE test SCHEMAFULL PERMISSIONS FOR create, update, delete NONE FOR select WHERE public = true;").unwrap();
|
let query = parse("DEFINE TABLE test SCHEMAFULL PERMISSIONS FOR create, update, delete NONE FOR select WHERE public = true;").unwrap();
|
||||||
assert_eq!(format!("{}", query), "DEFINE TABLE test TYPE ANY SCHEMAFULL PERMISSIONS FOR select WHERE public = true, FOR create, update, delete NONE;");
|
assert_eq!(format!("{}", query), "DEFINE TABLE test TYPE NORMAL SCHEMAFULL PERMISSIONS FOR select WHERE public = true, FOR create, update, delete NONE;");
|
||||||
assert_eq!(format!("{:#}", query), "DEFINE TABLE test TYPE ANY SCHEMAFULL\n\tPERMISSIONS\n\t\tFOR select\n\t\t\tWHERE public = true\n\t\tFOR create, update, delete NONE\n;");
|
assert_eq!(format!("{:#}", query), "DEFINE TABLE test TYPE NORMAL SCHEMAFULL\n\tPERMISSIONS\n\t\tFOR select\n\t\t\tWHERE public = true\n\t\tFOR create, update, delete NONE\n;");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -646,6 +646,8 @@ impl Parser<'_> {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut kind: Option<TableType> = None;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.peek_kind() {
|
match self.peek_kind() {
|
||||||
t!("COMMENT") => {
|
t!("COMMENT") => {
|
||||||
|
@ -661,15 +663,15 @@ impl Parser<'_> {
|
||||||
match self.peek_kind() {
|
match self.peek_kind() {
|
||||||
t!("NORMAL") => {
|
t!("NORMAL") => {
|
||||||
self.pop_peek();
|
self.pop_peek();
|
||||||
res.kind = TableType::Normal;
|
kind = Some(TableType::Normal);
|
||||||
}
|
}
|
||||||
t!("RELATION") => {
|
t!("RELATION") => {
|
||||||
self.pop_peek();
|
self.pop_peek();
|
||||||
res.kind = TableType::Relation(self.parse_relation_schema()?);
|
kind = Some(TableType::Relation(self.parse_relation_schema()?));
|
||||||
}
|
}
|
||||||
t!("ANY") => {
|
t!("ANY") => {
|
||||||
self.pop_peek();
|
self.pop_peek();
|
||||||
res.kind = TableType::Any;
|
kind = Some(TableType::Any);
|
||||||
}
|
}
|
||||||
x => unexpected!(self, x, "`NORMAL`, `RELATION`, or `ANY`"),
|
x => unexpected!(self, x, "`NORMAL`, `RELATION`, or `ANY`"),
|
||||||
}
|
}
|
||||||
|
@ -681,6 +683,9 @@ impl Parser<'_> {
|
||||||
t!("SCHEMAFULL") => {
|
t!("SCHEMAFULL") => {
|
||||||
self.pop_peek();
|
self.pop_peek();
|
||||||
res.full = true;
|
res.full = true;
|
||||||
|
if kind.is_none() {
|
||||||
|
kind = Some(TableType::Normal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t!("PERMISSIONS") => {
|
t!("PERMISSIONS") => {
|
||||||
self.pop_peek();
|
self.pop_peek();
|
||||||
|
@ -708,6 +713,10 @@ impl Parser<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(kind) = kind {
|
||||||
|
res.kind = kind;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1410,7 +1410,7 @@ fn parse_define_table() {
|
||||||
comment: None,
|
comment: None,
|
||||||
if_not_exists: false,
|
if_not_exists: false,
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
kind: TableType::Any,
|
kind: TableType::Normal,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ fn statements() -> Vec<Statement> {
|
||||||
comment: None,
|
comment: None,
|
||||||
if_not_exists: false,
|
if_not_exists: false,
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
kind: TableType::Any,
|
kind: TableType::Normal,
|
||||||
})),
|
})),
|
||||||
Statement::Define(DefineStatement::Event(DefineEventStatement {
|
Statement::Define(DefineStatement::Event(DefineEventStatement {
|
||||||
name: Ident("event".to_owned()),
|
name: Ident("event".to_owned()),
|
||||||
|
|
|
@ -179,7 +179,7 @@ async fn define_statement_table_schemafull() -> Result<(), Error> {
|
||||||
functions: {},
|
functions: {},
|
||||||
models: {},
|
models: {},
|
||||||
params: {},
|
params: {},
|
||||||
tables: { test: 'DEFINE TABLE test TYPE ANY SCHEMAFULL PERMISSIONS NONE' },
|
tables: { test: 'DEFINE TABLE test TYPE NORMAL SCHEMAFULL PERMISSIONS NONE' },
|
||||||
users: {},
|
users: {},
|
||||||
}",
|
}",
|
||||||
)?;
|
)?;
|
||||||
|
@ -208,7 +208,7 @@ async fn define_statement_table_schemaful() -> Result<(), Error> {
|
||||||
functions: {},
|
functions: {},
|
||||||
models: {},
|
models: {},
|
||||||
params: {},
|
params: {},
|
||||||
tables: { test: 'DEFINE TABLE test TYPE ANY SCHEMAFULL PERMISSIONS NONE' },
|
tables: { test: 'DEFINE TABLE test TYPE NORMAL SCHEMAFULL PERMISSIONS NONE' },
|
||||||
users: {},
|
users: {},
|
||||||
}",
|
}",
|
||||||
);
|
);
|
||||||
|
@ -248,7 +248,7 @@ async fn define_statement_table_foreigntable() -> Result<(), Error> {
|
||||||
models: {},
|
models: {},
|
||||||
params: {},
|
params: {},
|
||||||
tables: {
|
tables: {
|
||||||
test: 'DEFINE TABLE test TYPE ANY SCHEMAFULL PERMISSIONS NONE',
|
test: 'DEFINE TABLE test TYPE NORMAL SCHEMAFULL PERMISSIONS NONE',
|
||||||
view: 'DEFINE TABLE view TYPE ANY SCHEMALESS AS SELECT count() FROM test GROUP ALL PERMISSIONS NONE',
|
view: 'DEFINE TABLE view TYPE ANY SCHEMALESS AS SELECT count() FROM test GROUP ALL PERMISSIONS NONE',
|
||||||
},
|
},
|
||||||
users: {},
|
users: {},
|
||||||
|
@ -280,7 +280,7 @@ async fn define_statement_table_foreigntable() -> Result<(), Error> {
|
||||||
models: {},
|
models: {},
|
||||||
params: {},
|
params: {},
|
||||||
tables: {
|
tables: {
|
||||||
test: 'DEFINE TABLE test TYPE ANY SCHEMAFULL PERMISSIONS NONE',
|
test: 'DEFINE TABLE test TYPE NORMAL SCHEMAFULL PERMISSIONS NONE',
|
||||||
},
|
},
|
||||||
users: {},
|
users: {},
|
||||||
}",
|
}",
|
||||||
|
|
Loading…
Reference in a new issue