example of a custom dialect which allows date('xxx') syntax by removing 'date' from the list of keywords
This commit is contained in:
parent
206982cd0a
commit
1a1913e7b8
|
@ -90,7 +90,8 @@ Test-Suite Tests
|
||||||
Language.SQL.SimpleSQL.Tests,
|
Language.SQL.SimpleSQL.Tests,
|
||||||
Language.SQL.SimpleSQL.Tpch,
|
Language.SQL.SimpleSQL.Tpch,
|
||||||
Language.SQL.SimpleSQL.ScalarExprs,
|
Language.SQL.SimpleSQL.ScalarExprs,
|
||||||
Language.SQL.SimpleSQL.LexerTests
|
Language.SQL.SimpleSQL.LexerTests,
|
||||||
|
Language.SQL.SimpleSQL.CustomDialect
|
||||||
|
|
||||||
other-extensions: TupleSections,DeriveDataTypeable
|
other-extensions: TupleSections,DeriveDataTypeable
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
11
tools/Language/SQL/SimpleSQL/CustomDialect.lhs
Normal file
11
tools/Language/SQL/SimpleSQL/CustomDialect.lhs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
> module Language.SQL.SimpleSQL.CustomDialect (customDialectTests) where
|
||||||
|
|
||||||
|
> import Language.SQL.SimpleSQL.TestTypes
|
||||||
|
|
||||||
|
> customDialectTests :: TestItem
|
||||||
|
> customDialectTests = Group "custom dialect tests" (map (ParseQueryExpr myDialect) sometests
|
||||||
|
> ++ [ParseScalarExprFails ansi2011 "SELECT DATE('2000-01-01')"])
|
||||||
|
> where
|
||||||
|
> myDialect = ansi2011 {diKeywords = filter (/="date") (diKeywords ansi2011)}
|
||||||
|
> sometests = ["SELECT DATE('2000-01-01')"]
|
|
@ -4,11 +4,12 @@ Tests.lhs module for the 'interpreter'.
|
||||||
|
|
||||||
> module Language.SQL.SimpleSQL.TestTypes
|
> module Language.SQL.SimpleSQL.TestTypes
|
||||||
> (TestItem(..)
|
> (TestItem(..)
|
||||||
> ,ansi2011,mysql,postgres,oracle,sqlserver
|
> ,module Language.SQL.SimpleSQL.Dialect
|
||||||
> ,diOdbc) where
|
> ) where
|
||||||
|
|
||||||
> import Language.SQL.SimpleSQL.Syntax
|
> import Language.SQL.SimpleSQL.Syntax
|
||||||
> import Language.SQL.SimpleSQL.Lex (Token)
|
> import Language.SQL.SimpleSQL.Lex (Token)
|
||||||
|
> import Language.SQL.SimpleSQL.Dialect
|
||||||
|
|
||||||
TODO: maybe make the dialect args into [dialect], then each test
|
TODO: maybe make the dialect args into [dialect], then each test
|
||||||
checks all the dialects mentioned work, and all the dialects not
|
checks all the dialects mentioned work, and all the dialects not
|
||||||
|
|
|
@ -38,6 +38,7 @@ test data to the Test.Framework tests.
|
||||||
|
|
||||||
> import Language.SQL.SimpleSQL.MySQL
|
> import Language.SQL.SimpleSQL.MySQL
|
||||||
> import Language.SQL.SimpleSQL.Oracle
|
> import Language.SQL.SimpleSQL.Oracle
|
||||||
|
> 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.
|
||||||
|
@ -62,6 +63,7 @@ order on the generated documentation.
|
||||||
> ,sql2011BitsTests
|
> ,sql2011BitsTests
|
||||||
> ,mySQLTests
|
> ,mySQLTests
|
||||||
> ,oracleTests
|
> ,oracleTests
|
||||||
|
> ,customDialectTests
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
> tests :: T.TestTree
|
> tests :: T.TestTree
|
||||||
|
|
Loading…
Reference in a new issue