Add non-comma separated constraint dialect toggle
This commit is contained in:
parent
51157d502e
commit
f180d1070b
|
@ -92,6 +92,8 @@ Data types to represent different dialect options
|
|||
> ,diConvertFunction :: Bool
|
||||
> -- | allow creating autoincrement columns
|
||||
> ,diAutoincrement :: Bool
|
||||
> -- | allow omitting the comma between constraint clauses
|
||||
> ,diNonCommaSeparatedConstraints :: Bool
|
||||
> }
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
|
||||
|
@ -115,6 +117,7 @@ Data types to represent different dialect options
|
|||
> ,diSqlServerSymbols = False
|
||||
> ,diConvertFunction = False
|
||||
> ,diAutoincrement = False
|
||||
> ,diNonCommaSeparatedConstraints = False
|
||||
> }
|
||||
|
||||
> -- | mysql dialect
|
||||
|
|
|
@ -1510,10 +1510,14 @@ TODO: change style
|
|||
|
||||
> createTable :: Parser Statement
|
||||
> createTable = do
|
||||
> d <- getState
|
||||
> let
|
||||
> parseColumnDef = TableColumnDef <$> columnDef
|
||||
> parseConstraintDef = uncurry TableConstraintDef <$> tableConstraintDef
|
||||
> constraints = sepBy parseConstraintDef (optional comma)
|
||||
> separator = if diNonCommaSeparatedConstraints d
|
||||
> then optional comma
|
||||
> else void comma
|
||||
> constraints = sepBy parseConstraintDef separator
|
||||
> entries = ((:) <$> parseColumnDef <*> ((comma >> entries) <|> pure [])) <|> constraints
|
||||
>
|
||||
> keyword_ "table" >>
|
||||
|
|
|
@ -651,7 +651,7 @@ defintely skip
|
|||
> DefaultReferentialAction DefaultReferentialAction
|
||||
> ])
|
||||
|
||||
> ,(TestStatement ansi2011
|
||||
> ,(TestStatement ansi2011 { diNonCommaSeparatedConstraints = True }
|
||||
> "create table t (a int, b int,\n\
|
||||
> \ foreign key (a) references u(c)\n\
|
||||
> \ foreign key (b) references v(d));"
|
||||
|
|
Loading…
Reference in a new issue