diff --git a/Language/SQL/SimpleSQL/Dialect.lhs b/Language/SQL/SimpleSQL/Dialect.lhs index ab93c8c..30c2d08 100644 --- a/Language/SQL/SimpleSQL/Dialect.lhs +++ b/Language/SQL/SimpleSQL/Dialect.lhs @@ -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 diff --git a/Language/SQL/SimpleSQL/Parse.lhs b/Language/SQL/SimpleSQL/Parse.lhs index 4fdceb8..29c098c 100644 --- a/Language/SQL/SimpleSQL/Parse.lhs +++ b/Language/SQL/SimpleSQL/Parse.lhs @@ -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" >> diff --git a/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs b/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs index 0e7acd6..f10f479 100644 --- a/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs +++ b/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs @@ -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));"