diff --git a/Language/SQL/SimpleSQL/Dialect.lhs b/Language/SQL/SimpleSQL/Dialect.lhs index c6bcfb3..ab93c8c 100644 --- a/Language/SQL/SimpleSQL/Dialect.lhs +++ b/Language/SQL/SimpleSQL/Dialect.lhs @@ -90,6 +90,8 @@ Data types to represent different dialect options > ,diSqlServerSymbols :: Bool > -- | allow sql server style for CONVERT function in format CONVERT(data_type(length), expression, style) > ,diConvertFunction :: Bool +> -- | allow creating autoincrement columns +> ,diAutoincrement :: Bool > } > deriving (Eq,Show,Read,Data,Typeable) @@ -112,6 +114,7 @@ Data types to represent different dialect options > ,diPostgresSymbols = False > ,diSqlServerSymbols = False > ,diConvertFunction = False +> ,diAutoincrement = False > } > -- | mysql dialect diff --git a/Language/SQL/SimpleSQL/Parse.lhs b/Language/SQL/SimpleSQL/Parse.lhs index 56e5b78..7674c51 100644 --- a/Language/SQL/SimpleSQL/Parse.lhs +++ b/Language/SQL/SimpleSQL/Parse.lhs @@ -1595,7 +1595,10 @@ TODO: change style > unique = ColUniqueConstraint <$ keyword_ "unique" > primaryKey = do > keywords_ ["primary", "key"] -> autoincrement <- optionMaybe (keyword_ "autoincrement") +> d <- getState +> autoincrement <- if diAutoincrement d +> then optionMaybe (keyword_ "autoincrement") +> else pure Nothing > pure $ ColPrimaryKeyConstraint $ isJust autoincrement > check = keyword_ "check" >> ColCheckConstraint <$> parens scalarExpr > references = keyword_ "references" >> diff --git a/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs b/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs index 3ced1d4..d60ae64 100644 --- a/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs +++ b/tools/Language/SQL/SimpleSQL/SQL2011Schema.lhs @@ -334,7 +334,7 @@ todo: constraint characteristics > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing (ColPrimaryKeyConstraint False)]]) -> ,(TestStatement ansi2011 +> ,(TestStatement ansi2011 { diAutoincrement = True } > "create table t (a int primary key autoincrement);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing