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