2024-01-09 01:07:47 +01:00
|
|
|
|
|
|
|
{-
|
|
|
|
These are the tests for the queryExprs parsing which parses multiple
|
|
|
|
query expressions from one string.
|
|
|
|
-}
|
|
|
|
|
2024-01-10 08:40:24 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2024-01-09 01:07:47 +01:00
|
|
|
module Language.SQL.SimpleSQL.QueryExprs (queryExprsTests) where
|
|
|
|
|
|
|
|
import Language.SQL.SimpleSQL.TestTypes
|
|
|
|
import Language.SQL.SimpleSQL.Syntax
|
2024-02-04 17:00:59 +01:00
|
|
|
import Language.SQL.SimpleSQL.TestRunners
|
|
|
|
import Data.Text (Text)
|
2024-01-09 01:07:47 +01:00
|
|
|
|
|
|
|
queryExprsTests :: TestItem
|
2024-02-04 17:00:59 +01:00
|
|
|
queryExprsTests = Group "query exprs"
|
|
|
|
[q "select 1" [ms]
|
|
|
|
,q "select 1;" [ms]
|
|
|
|
,q "select 1;select 1" [ms,ms]
|
|
|
|
,q " select 1;select 1; " [ms,ms]
|
|
|
|
,q "SELECT CURRENT_TIMESTAMP;"
|
|
|
|
[SelectStatement $ toQueryExpr $ makeSelect
|
|
|
|
{msSelectList = [(Iden [Name Nothing "CURRENT_TIMESTAMP"],Nothing)]}]
|
|
|
|
,q "SELECT \"CURRENT_TIMESTAMP\";"
|
|
|
|
[SelectStatement $ toQueryExpr $ makeSelect
|
|
|
|
{msSelectList = [(Iden [Name (Just ("\"","\"")) "CURRENT_TIMESTAMP"],Nothing)]}]
|
2024-01-09 01:07:47 +01:00
|
|
|
]
|
|
|
|
where
|
2024-01-11 15:45:20 +01:00
|
|
|
ms = SelectStatement $ toQueryExpr $ makeSelect {msSelectList = [(NumLit "1",Nothing)]}
|
2024-02-04 17:00:59 +01:00
|
|
|
q :: HasCallStack => Text -> [Statement] -> TestItem
|
|
|
|
q src ast = testStatements ansi2011 src ast
|