1
Fork 0

add schema support for create index referenced table, and add some tests

This commit is contained in:
Jake 2021-10-19 16:32:25 +01:00
parent f019c2d1ed
commit 05481371dd
6 changed files with 34 additions and 3 deletions

View file

@ -1511,7 +1511,7 @@ TODO: change style
> <$> ((keyword_ "index" >> pure False) <|> > <$> ((keyword_ "index" >> pure False) <|>
> (keywords_ ["unique", "index"] >> pure True)) > (keywords_ ["unique", "index"] >> pure True))
> <*> names > <*> names
> <*> (keyword_ "on" >> name) > <*> (keyword_ "on" >> names)
> <*> parens (commaSep1 name) > <*> parens (commaSep1 name)
> columnDef :: Parser ColumnDef > columnDef :: Parser ColumnDef

View file

@ -531,6 +531,15 @@ Try to do this when this code is ported to a modern pretty printing lib.
> statement _ (DropAssertion nm db) = > statement _ (DropAssertion nm db) =
> text "drop" <+> text "assertion" <+> names nm <+> dropBehav db > text "drop" <+> text "assertion" <+> names nm <+> dropBehav db
> statement _ (CreateIndex un nm tbl cols) =
> texts (if un
> then ["create","unique","index"]
> else ["create","index"])
> <+> names nm
> <+> text "on"
> <+> names tbl
> <+> parens (commaSep $ map name cols)
== dml == dml
> statement d (SelectStatement q) = queryExpr d q > statement d (SelectStatement q) = queryExpr d q

View file

@ -454,7 +454,7 @@ I'm not sure if this is valid syntax or not.
> | CreateTable [Name] [TableElement] > | CreateTable [Name] [TableElement]
> | AlterTable [Name] AlterTableAction > | AlterTable [Name] AlterTableAction
> | DropTable [Name] DropBehaviour > | DropTable [Name] DropBehaviour
> | CreateIndex Bool [Name] Name [Name] > | CreateIndex Bool [Name] [Name] [Name]
> | CreateView Bool [Name] (Maybe [Name]) > | CreateView Bool [Name] (Maybe [Name])
> QueryExpr (Maybe CheckOption) > QueryExpr (Maybe CheckOption)
> | DropView [Name] DropBehaviour > | DropView [Name] DropBehaviour

View file

@ -86,7 +86,9 @@ Test-Suite Tests
Language.SQL.SimpleSQL.ScalarExprs, Language.SQL.SimpleSQL.ScalarExprs,
Language.SQL.SimpleSQL.LexerTests, Language.SQL.SimpleSQL.LexerTests,
Language.SQL.SimpleSQL.CustomDialect, Language.SQL.SimpleSQL.CustomDialect,
Language.SQL.SimpleSQL.EmptyStatement Language.SQL.SimpleSQL.EmptyStatement,
Language.SQL.SimpleSQL.CreateIndex
ghc-options: -threaded ghc-options: -threaded
executable SimpleSqlParserTool executable SimpleSqlParserTool

View file

@ -0,0 +1,17 @@
> module Language.SQL.SimpleSQL.CreateIndex where
>
> import Language.SQL.SimpleSQL.Syntax
> import Language.SQL.SimpleSQL.TestTypes
>
> createIndexTests :: TestItem
> createIndexTests = Group "create index tests"
> [TestStatement ansi2011 "create index a on tbl(c1)"
> $ CreateIndex False [nm "a"] [nm "tbl"] [nm "c1"]
> ,TestStatement ansi2011 "create index a.b on sc.tbl (c1, c2)"
> $ CreateIndex False [nm "a", nm "b"] [nm "sc", nm "tbl"] [nm "c1", nm "c2"]
> ,TestStatement ansi2011 "create unique index a on tbl(c1)"
> $ CreateIndex True [nm "a"] [nm "tbl"] [nm "c1"]
> ]
> where
> nm = Name Nothing

View file

@ -30,6 +30,7 @@ test data to the Test.Framework tests.
> import Language.SQL.SimpleSQL.Tpch > import Language.SQL.SimpleSQL.Tpch
> import Language.SQL.SimpleSQL.LexerTests > import Language.SQL.SimpleSQL.LexerTests
> import Language.SQL.SimpleSQL.EmptyStatement > import Language.SQL.SimpleSQL.EmptyStatement
> import Language.SQL.SimpleSQL.CreateIndex
> import Language.SQL.SimpleSQL.SQL2011Queries > import Language.SQL.SimpleSQL.SQL2011Queries
> import Language.SQL.SimpleSQL.SQL2011AccessControl > import Language.SQL.SimpleSQL.SQL2011AccessControl
@ -41,6 +42,7 @@ test data to the Test.Framework tests.
> import Language.SQL.SimpleSQL.Oracle > import Language.SQL.SimpleSQL.Oracle
> import Language.SQL.SimpleSQL.CustomDialect > import Language.SQL.SimpleSQL.CustomDialect
Order the tests to start from the simplest first. This is also the Order the tests to start from the simplest first. This is also the
order on the generated documentation. order on the generated documentation.
@ -66,6 +68,7 @@ order on the generated documentation.
> ,oracleTests > ,oracleTests
> ,customDialectTests > ,customDialectTests
> ,emptyStatementTests > ,emptyStatementTests
> ,createIndexTests
> ] > ]
> tests :: T.TestTree > tests :: T.TestTree