minor enhancements for sqlserver dialect
This commit is contained in:
parent
05481371dd
commit
efd4dea6ff
|
@ -88,6 +88,8 @@ Data types to represent different dialect options
|
|||
> ,diPostgresSymbols :: Bool
|
||||
> -- | allow sql server style symbols
|
||||
> ,diSqlServerSymbols :: Bool
|
||||
> -- | allow sql server style forCONVERT function in format @CONVERT(data_type(length), expression, style)@
|
||||
> ,diConvertFunction :: Bool
|
||||
> }
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
|
||||
|
@ -109,6 +111,7 @@ Data types to represent different dialect options
|
|||
> ,diEString = False
|
||||
> ,diPostgresSymbols = False
|
||||
> ,diSqlServerSymbols = False
|
||||
> ,diConvertFunction = False
|
||||
> }
|
||||
|
||||
> -- | mysql dialect
|
||||
|
@ -133,7 +136,9 @@ Data types to represent different dialect options
|
|||
> sqlserver = ansi2011 {diSquareBracketQuotedIden = True
|
||||
> ,diAtIdentifier = True
|
||||
> ,diHashIdentifier = True
|
||||
> ,diSqlServerSymbols = True }
|
||||
> ,diOdbc = True
|
||||
> ,diSqlServerSymbols = True
|
||||
> ,diConvertFunction = True}
|
||||
|
||||
> addLimit :: Dialect -> Dialect
|
||||
> addLimit d = d {diKeywords = "limit": diKeywords d
|
||||
|
|
|
@ -597,6 +597,16 @@ cast: cast(expr as type)
|
|||
> parens (Cast <$> scalarExpr
|
||||
> <*> (keyword_ "as" *> typeName))
|
||||
|
||||
=== convert
|
||||
|
||||
convertSqlServer: SqlServer dialect CONVERT(data_type(length), expression, style)
|
||||
|
||||
> convertSqlServer :: Parser ScalarExpr
|
||||
> convertSqlServer = guardDialect diConvertFunction
|
||||
> *> keyword_ "convert" *>
|
||||
> parens (Convert <$> typeName <*> (comma *> scalarExpr)
|
||||
> <*> optionMaybe (comma *> unsignedInteger))
|
||||
|
||||
=== exists, unique
|
||||
|
||||
subquery expression:
|
||||
|
@ -1175,6 +1185,7 @@ documenting/fixing.
|
|||
> ,parensExpr
|
||||
> ,caseExpr
|
||||
> ,cast
|
||||
> ,convertSqlServer
|
||||
> ,arrayCtor
|
||||
> ,multisetCtor
|
||||
> ,nextValueFor
|
||||
|
@ -2027,7 +2038,7 @@ It is only allowed when all the strings are quoted with ' atm.
|
|||
> L.Identifier q p | map toLower p `notElem` blackList -> Just (q,p)
|
||||
> _ -> Nothing)
|
||||
|
||||
> unquotedIdentifierTok :: [String] -> Maybe String -> Parser String
|
||||
> unquotedIdentifierTok :: [String] -> Maybe String -> Parser String
|
||||
> unquotedIdentifierTok blackList kw = mytoken (\tok ->
|
||||
> case (kw,tok) of
|
||||
> (Nothing, L.Identifier Nothing p) | map toLower p `notElem` blackList -> Just p
|
||||
|
|
|
@ -167,6 +167,9 @@
|
|||
> -- | cast(a as typename)
|
||||
> | Cast ScalarExpr TypeName
|
||||
|
||||
> -- | convert expression to given datatype @CONVERT(data_type(length), expression, style)@
|
||||
> | Convert TypeName ScalarExpr (Maybe Integer)
|
||||
|
||||
> -- | case expression. both flavours supported
|
||||
> | Case
|
||||
> {caseTest :: Maybe ScalarExpr -- ^ test value
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
0.6.1 added odbc handling to sqlsqerver dialect
|
||||
added sqlserver dialect case for convert function
|
||||
0.6.0
|
||||
tested with ghc 8.8.1 also
|
||||
change the dialect handling - now a dialect is a bunch of flags
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cabal-version: 2.2
|
||||
|
||||
name: simple-sql-parser
|
||||
version: 0.6.0
|
||||
version: 0.6.1
|
||||
synopsis: A parser for SQL.
|
||||
|
||||
description:
|
||||
|
|
12
stack.yaml.lock
Normal file
12
stack.yaml.lock
Normal file
|
@ -0,0 +1,12 @@
|
|||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages: []
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 500539
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/27.yaml
|
||||
sha256: 690db832392afe55733b4c7023fd29b1b1c660ee42f1fb505b86b07394ca994e
|
||||
original: lts-13.27
|
Loading…
Reference in a new issue