@@ -406,6 +406,8 @@ func statementToJSON(stmt ast.Statement) jsonNode {
406406 return createTypeUddtStatementToJSON (s )
407407 case * ast.CreateTypeUdtStatement :
408408 return createTypeUdtStatementToJSON (s )
409+ case * ast.CreateTypeTableStatement :
410+ return createTypeTableStatementToJSON (s )
409411 case * ast.CreateXmlIndexStatement :
410412 return createXmlIndexStatementToJSON (s )
411413 case * ast.CreatePartitionFunctionStatement :
@@ -2816,6 +2818,23 @@ func (p *Parser) parseColumnDefinition() (*ast.ColumnDefinition, error) {
28162818 // Parse column name (parseIdentifier already calls nextToken)
28172819 col .ColumnIdentifier = p .parseIdentifier ()
28182820
2821+ // Check for computed column (AS expression)
2822+ if strings .ToUpper (p .curTok .Literal ) == "AS" {
2823+ p .nextToken () // consume AS
2824+ // Parse computed column expression
2825+ expr , err := p .parseScalarExpression ()
2826+ if err != nil {
2827+ return nil , err
2828+ }
2829+ col .ComputedColumnExpression = expr
2830+ // Check for PERSISTED
2831+ if strings .ToUpper (p .curTok .Literal ) == "PERSISTED" {
2832+ col .IsPersisted = true
2833+ p .nextToken () // consume PERSISTED
2834+ }
2835+ return col , nil
2836+ }
2837+
28192838 // Parse data type - be lenient if no data type is provided
28202839 dataType , err := p .parseDataTypeReference ()
28212840 if err != nil {
@@ -3990,6 +4009,9 @@ func columnDefinitionToJSON(c *ast.ColumnDefinition) jsonNode {
39904009 "IsMasked" : c .IsMasked ,
39914010 "ColumnIdentifier" : identifierToJSON (c .ColumnIdentifier ),
39924011 }
4012+ if c .ComputedColumnExpression != nil {
4013+ node ["ComputedColumnExpression" ] = scalarExpressionToJSON (c .ComputedColumnExpression )
4014+ }
39934015 if c .IdentityOptions != nil {
39944016 node ["IdentityOptions" ] = identityOptionsToJSON (c .IdentityOptions )
39954017 }
@@ -4056,9 +4078,12 @@ func constraintDefinitionToJSON(c ast.ConstraintDefinition) jsonNode {
40564078func uniqueConstraintToJSON (c * ast.UniqueConstraintDefinition ) jsonNode {
40574079 node := jsonNode {
40584080 "$type" : "UniqueConstraintDefinition" ,
4059- "Clustered" : c .Clustered ,
40604081 "IsPrimaryKey" : c .IsPrimaryKey ,
40614082 }
4083+ // Output Clustered if it's true, or if IndexType is set (meaning NONCLUSTERED was explicitly specified)
4084+ if c .Clustered || c .IndexType != nil {
4085+ node ["Clustered" ] = c .Clustered
4086+ }
40624087 if c .ConstraintIdentifier != nil {
40634088 node ["ConstraintIdentifier" ] = identifierToJSON (c .ConstraintIdentifier )
40644089 }
@@ -6566,13 +6591,19 @@ func (p *Parser) parseCreateFunctionStatement() (*ast.CreateFunctionStatement, e
65666591
65676592 // Parse data type if present
65686593 if p .curTok .Type != TokenRParen && p .curTok .Type != TokenComma {
6569- dataType , err := p .parseDataType ()
6594+ dataType , err := p .parseDataTypeReference ()
65706595 if err != nil {
65716596 return nil , err
65726597 }
65736598 param .DataType = dataType
65746599 }
65756600
6601+ // Check for READONLY modifier
6602+ if strings .ToUpper (p .curTok .Literal ) == "READONLY" {
6603+ param .Modifier = "ReadOnly"
6604+ p .nextToken ()
6605+ }
6606+
65766607 stmt .Parameters = append (stmt .Parameters , param )
65776608
65786609 if p .curTok .Type == TokenComma {
@@ -6595,7 +6626,7 @@ func (p *Parser) parseCreateFunctionStatement() (*ast.CreateFunctionStatement, e
65956626 p .nextToken ()
65966627
65976628 // Parse return type
6598- returnDataType , err := p .parseDataType ()
6629+ returnDataType , err := p .parseDataTypeReference ()
65996630 if err != nil {
66006631 p .skipToEndOfStatement ()
66016632 return stmt , nil
@@ -9347,6 +9378,19 @@ func createTypeUdtStatementToJSON(s *ast.CreateTypeUdtStatement) jsonNode {
93479378 return node
93489379}
93499380
9381+ func createTypeTableStatementToJSON (s * ast.CreateTypeTableStatement ) jsonNode {
9382+ node := jsonNode {
9383+ "$type" : "CreateTypeTableStatement" ,
9384+ }
9385+ if s .Definition != nil {
9386+ node ["Definition" ] = tableDefinitionToJSON (s .Definition )
9387+ }
9388+ if s .Name != nil {
9389+ node ["Name" ] = schemaObjectNameToJSON (s .Name )
9390+ }
9391+ return node
9392+ }
9393+
93509394func createXmlIndexStatementToJSON (s * ast.CreateXmlIndexStatement ) jsonNode {
93519395 node := jsonNode {
93529396 "$type" : "CreateXmlIndexStatement" ,
0 commit comments