1
Fork 0

Add autoincrement option to dialect

This commit is contained in:
Matei Adriel 2024-01-08 22:10:14 +01:00
parent c997e3196c
commit d53afd905e
No known key found for this signature in database
3 changed files with 8 additions and 2 deletions
Language/SQL/SimpleSQL

View file

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

View file

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