Add autoincrement option to dialect
This commit is contained in:
parent
c997e3196c
commit
d53afd905e
|
@ -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
|
||||
|
|
|
@ -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" >>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue