Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ast/create_table_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ast

// CreateTableStatement represents a CREATE TABLE statement
type CreateTableStatement struct {
SchemaObjectName *SchemaObjectName
AsEdge bool
AsFileTable bool
AsNode bool
Definition *TableDefinition
SchemaObjectName *SchemaObjectName
AsEdge bool
AsFileTable bool
AsNode bool
Definition *TableDefinition
OnFileGroupOrPartitionScheme *FileGroupOrPartitionScheme
TextImageOn *IdentifierOrValueExpression
}

func (s *CreateTableStatement) node() {}
Expand Down
36 changes: 36 additions & 0 deletions parser/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,32 @@ func (p *Parser) parseCreateTableStatement() (*ast.CreateTableStatement, error)
p.nextToken()
}

// Parse optional ON filegroup and TEXTIMAGE_ON filegroup clauses
for {
upperLit := strings.ToUpper(p.curTok.Literal)
if p.curTok.Type == TokenOn {
p.nextToken() // consume ON
// Parse filegroup identifier
ident := p.parseIdentifier()
stmt.OnFileGroupOrPartitionScheme = &ast.FileGroupOrPartitionScheme{
Name: &ast.IdentifierOrValueExpression{
Value: ident.Value,
Identifier: ident,
},
}
} else if upperLit == "TEXTIMAGE_ON" {
p.nextToken() // consume TEXTIMAGE_ON
// Parse filegroup identifier
ident := p.parseIdentifier()
stmt.TextImageOn = &ast.IdentifierOrValueExpression{
Value: ident.Value,
Identifier: ident,
}
} else {
break
}
}

// Skip optional semicolon
if p.curTok.Type == TokenSemicolon {
p.nextToken()
Expand Down Expand Up @@ -2556,6 +2582,10 @@ func (p *Parser) parseColumnDefinition() (*ast.ColumnDefinition, error) {
p.nextToken() // consume REPLICATION
identityOpts.NotForReplication = true
}
} else if p.curTok.Type == TokenNull {
// NOT NULL after IDENTITY - handle it here since NOT was already consumed
p.nextToken() // consume NULL
col.Constraints = append(col.Constraints, &ast.NullableConstraintDefinition{Nullable: false})
}
}

Expand Down Expand Up @@ -2875,6 +2905,12 @@ func createTableStatementToJSON(s *ast.CreateTableStatement) jsonNode {
if s.Definition != nil {
node["Definition"] = tableDefinitionToJSON(s.Definition)
}
if s.OnFileGroupOrPartitionScheme != nil {
node["OnFileGroupOrPartitionScheme"] = fileGroupOrPartitionSchemeToJSON(s.OnFileGroupOrPartitionScheme)
}
if s.TextImageOn != nil {
node["TextImageOn"] = identifierOrValueExpressionToJSON(s.TextImageOn)
}
return node
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}
2 changes: 1 addition & 1 deletion parser/testdata/TSqlParserTestScript2/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}
Loading