1
Fork 0

example of a custom dialect which allows date('xxx') syntax by removing 'date' from the list of keywords

This commit is contained in:
Jake Wheat 2019-08-31 13:50:12 +01:00
parent 206982cd0a
commit 1a1913e7b8
4 changed files with 18 additions and 3 deletions

View file

@ -90,7 +90,8 @@ Test-Suite Tests
Language.SQL.SimpleSQL.Tests,
Language.SQL.SimpleSQL.Tpch,
Language.SQL.SimpleSQL.ScalarExprs,
Language.SQL.SimpleSQL.LexerTests
Language.SQL.SimpleSQL.LexerTests,
Language.SQL.SimpleSQL.CustomDialect
other-extensions: TupleSections,DeriveDataTypeable
default-language: Haskell2010

View 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')"]

View file

@ -4,11 +4,12 @@ Tests.lhs module for the 'interpreter'.
> module Language.SQL.SimpleSQL.TestTypes
> (TestItem(..)
> ,ansi2011,mysql,postgres,oracle,sqlserver
> ,diOdbc) where
> ,module Language.SQL.SimpleSQL.Dialect
> ) where
> import Language.SQL.SimpleSQL.Syntax
> import Language.SQL.SimpleSQL.Lex (Token)
> import Language.SQL.SimpleSQL.Dialect
TODO: maybe make the dialect args into [dialect], then each test
checks all the dialects mentioned work, and all the dialects not

View file

@ -38,6 +38,7 @@ test data to the Test.Framework tests.
> import Language.SQL.SimpleSQL.MySQL
> import Language.SQL.SimpleSQL.Oracle
> import Language.SQL.SimpleSQL.CustomDialect
Order the tests to start from the simplest first. This is also the
order on the generated documentation.
@ -62,6 +63,7 @@ order on the generated documentation.
> ,sql2011BitsTests
> ,mySQLTests
> ,oracleTests
> ,customDialectTests
> ]
> tests :: T.TestTree