Simplify SCHEMAFUL and SCHEMAFULL parsing definitions

Closes #220
This commit is contained in:
Tobie Morgan Hitchcock 2022-09-20 08:11:14 +01:00
parent d6b544771f
commit 0381b6dad2
2 changed files with 7 additions and 16 deletions

View file

@ -695,14 +695,7 @@ pub enum DefineTableOption {
} }
fn table_opts(i: &str) -> IResult<&str, DefineTableOption> { fn table_opts(i: &str) -> IResult<&str, DefineTableOption> {
alt(( alt((table_drop, table_view, table_schemaless, table_schemafull, table_permissions))(i)
table_drop,
table_view,
table_schemaless,
table_schemafull,
table_schemaful,
table_permissions,
))(i)
} }
fn table_drop(i: &str) -> IResult<&str, DefineTableOption> { fn table_drop(i: &str) -> IResult<&str, DefineTableOption> {
@ -725,13 +718,7 @@ fn table_schemaless(i: &str) -> IResult<&str, DefineTableOption> {
fn table_schemafull(i: &str) -> IResult<&str, DefineTableOption> { fn table_schemafull(i: &str) -> IResult<&str, DefineTableOption> {
let (i, _) = shouldbespace(i)?; let (i, _) = shouldbespace(i)?;
let (i, _) = tag_no_case("SCHEMAFULL")(i)?; let (i, _) = alt((tag_no_case("SCHEMAFULL"), tag_no_case("SCHEMAFUL")))(i)?;
Ok((i, DefineTableOption::Schemafull))
}
fn table_schemaful(i: &str) -> IResult<&str, DefineTableOption> {
let (i, _) = shouldbespace(i)?;
let (i, _) = tag_no_case("SCHEMAFUL")(i)?;
Ok((i, DefineTableOption::Schemafull)) Ok((i, DefineTableOption::Schemafull))
} }

View file

@ -116,13 +116,17 @@ async fn define_statement_table_schemaless() -> Result<(), Error> {
#[tokio::test] #[tokio::test]
async fn define_statement_table_schemafull() -> Result<(), Error> { async fn define_statement_table_schemafull() -> Result<(), Error> {
let sql = " let sql = "
DEFINE TABLE test SCHEMAFUL;
DEFINE TABLE test SCHEMAFULL; DEFINE TABLE test SCHEMAFULL;
INFO FOR DB; INFO FOR DB;
"; ";
let dbs = Datastore::new("memory").await?; let dbs = Datastore::new("memory").await?;
let ses = Session::for_kv().with_ns("test").with_db("test"); let ses = Session::for_kv().with_ns("test").with_db("test");
let res = &mut dbs.execute(&sql, &ses, None, false).await?; let res = &mut dbs.execute(&sql, &ses, None, false).await?;
assert_eq!(res.len(), 2); assert_eq!(res.len(), 3);
//
let tmp = res.remove(0).result;
assert!(tmp.is_ok());
// //
let tmp = res.remove(0).result; let tmp = res.remove(0).result;
assert!(tmp.is_ok()); assert!(tmp.is_ok());