add generation clause support to create table
This commit is contained in:
parent
e495e240c0
commit
4f80ec96d4
|
@ -1472,6 +1472,9 @@ TODO: change style
|
||||||
> defaultClause = choice [
|
> defaultClause = choice [
|
||||||
> keyword_ "default" >>
|
> keyword_ "default" >>
|
||||||
> DefaultClause <$> valueExpr
|
> DefaultClause <$> valueExpr
|
||||||
|
> -- todo: left factor
|
||||||
|
> ,try (keywords_ ["generated","always","as"] >>
|
||||||
|
> GenerationClause <$> parens valueExpr)
|
||||||
> ,keyword_ "generated" >>
|
> ,keyword_ "generated" >>
|
||||||
> IdentityColumnSpec
|
> IdentityColumnSpec
|
||||||
> <$> option GeneratedDefault
|
> <$> option GeneratedDefault
|
||||||
|
|
|
@ -463,6 +463,8 @@ which have been changed to try to improve the layout of the output.
|
||||||
> Nothing -> empty
|
> Nothing -> empty
|
||||||
> Just (DefaultClause def) ->
|
> Just (DefaultClause def) ->
|
||||||
> text "default" <+> valueExpr d def
|
> text "default" <+> valueExpr d def
|
||||||
|
> Just (GenerationClause e) ->
|
||||||
|
> texts ["generated","always","as"] <+> parens (valueExpr d e)
|
||||||
> Just (IdentityColumnSpec w o) ->
|
> Just (IdentityColumnSpec w o) ->
|
||||||
> text "generated"
|
> text "generated"
|
||||||
> <+> (case w of
|
> <+> (case w of
|
||||||
|
|
|
@ -504,7 +504,7 @@ I'm not sure if this is valid syntax or not.
|
||||||
> data DefaultClause =
|
> data DefaultClause =
|
||||||
> DefaultClause ValueExpr
|
> DefaultClause ValueExpr
|
||||||
> | IdentityColumnSpec IdentityWhen [SequenceGeneratorOption]
|
> | IdentityColumnSpec IdentityWhen [SequenceGeneratorOption]
|
||||||
> -- | GenerationClause
|
> | GenerationClause ValueExpr
|
||||||
> deriving (Eq,Show,Read,Data,Typeable)
|
> deriving (Eq,Show,Read,Data,Typeable)
|
||||||
|
|
||||||
> data IdentityWhen =
|
> data IdentityWhen =
|
||||||
|
|
|
@ -356,6 +356,16 @@ generated always (valueexpr)
|
||||||
<generation expression> ::=
|
<generation expression> ::=
|
||||||
<left paren> <value expression> <right paren>
|
<left paren> <value expression> <right paren>
|
||||||
|
|
||||||
|
> ,(TestStatement SQL2011
|
||||||
|
> "create table t (a int, \
|
||||||
|
> \ a2 int generated always as (a * 2));"
|
||||||
|
> $ CreateTable [Name "t"]
|
||||||
|
> [ColumnDef (Name "a") (TypeName [Name "int"]) Nothing
|
||||||
|
> ,ColumnDef (Name "a2") (TypeName [Name "int"])
|
||||||
|
> (Just $ GenerationClause
|
||||||
|
> (BinOp (Iden [Name "a"]) [Name "*"] (NumLit "2")))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
11.5 <default clause>
|
11.5 <default clause>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue