1
Fork 0

Add non-comma separated constraint dialect toggle

This commit is contained in:
Matei Adriel 2024-01-09 00:25:39 +01:00
parent 51157d502e
commit f180d1070b
No known key found for this signature in database
3 changed files with 9 additions and 2 deletions

View file

@ -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

View file

@ -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" >>

View file

@ -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));"