2024-01-09 01:07:47 +01:00
|
|
|
|
|
|
|
-- Tests for mysql dialect parsing
|
|
|
|
|
2024-01-10 08:40:24 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2024-01-09 01:07:47 +01:00
|
|
|
module Language.SQL.SimpleSQL.MySQL (mySQLTests) where
|
|
|
|
|
|
|
|
import Language.SQL.SimpleSQL.TestTypes
|
|
|
|
import Language.SQL.SimpleSQL.Syntax
|
2024-02-04 17:00:59 +01:00
|
|
|
import Language.SQL.SimpleSQL.TestRunners
|
2024-01-09 01:07:47 +01:00
|
|
|
|
|
|
|
mySQLTests :: TestItem
|
|
|
|
mySQLTests = Group "mysql dialect"
|
|
|
|
[backtickQuotes
|
|
|
|
,limit]
|
|
|
|
|
|
|
|
{-
|
|
|
|
backtick quotes
|
|
|
|
|
|
|
|
limit syntax
|
|
|
|
|
|
|
|
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
|
|
|
|
-}
|
|
|
|
|
|
|
|
backtickQuotes :: TestItem
|
2024-02-04 17:00:59 +01:00
|
|
|
backtickQuotes = Group "backtickQuotes"
|
|
|
|
[testScalarExpr mysql "`test`" $ Iden [Name (Just ("`","`")) "test"]
|
|
|
|
,testParseScalarExprFails ansi2011 "`test`"]
|
2024-01-09 01:07:47 +01:00
|
|
|
|
|
|
|
limit :: TestItem
|
2024-02-04 17:00:59 +01:00
|
|
|
limit = Group "queries"
|
|
|
|
[testQueryExpr mysql "select * from t limit 5"
|
|
|
|
$ toQueryExpr $ sel {msFetchFirst = Just (NumLit "5")}
|
|
|
|
,testParseQueryExprFails mysql "select a from t fetch next 10 rows only;"
|
|
|
|
,testParseQueryExprFails ansi2011 "select * from t limit 5"]
|
2024-01-09 01:07:47 +01:00
|
|
|
where
|
|
|
|
sel = makeSelect
|
2024-01-11 15:45:20 +01:00
|
|
|
{msSelectList = [(Star, Nothing)]
|
|
|
|
,msFrom = [TRSimple [Name Nothing "t"]]
|
2024-01-09 01:07:47 +01:00
|
|
|
}
|