Skip to content

Commit 987dad7

Browse files
committed
Add DelayedDurabilityDatabaseOption and CreateMessageType features, enable 3 tests
- Add DelayedDurabilityDatabaseOption type for ALTER DATABASE SET DELAYED_DURABILITY - Parse DELAYED_DURABILITY = DISABLED/ALLOWED/FORCED values - Add ValidationMethod, Owner, XmlSchemaCollectionName to CreateMessageTypeStatement - Parse CREATE MESSAGE TYPE ... AUTHORIZATION ... VALIDATION = ... Enable tests: - AlterDatabaseOptionsTests120 - Baselines120_AlterDatabaseOptionsTests120 - Baselines90_CreateMessageTypeStatementTests
1 parent 87d8334 commit 987dad7

8 files changed

Lines changed: 90 additions & 6 deletions

File tree

ast/alter_database_set_statement.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ type OnOffDatabaseOption struct {
3535
func (o *OnOffDatabaseOption) node() {}
3636
func (o *OnOffDatabaseOption) databaseOption() {}
3737

38+
// DelayedDurabilityDatabaseOption represents DELAYED_DURABILITY option
39+
type DelayedDurabilityDatabaseOption struct {
40+
OptionKind string // "DelayedDurability"
41+
Value string // "Disabled", "Allowed", "Forced"
42+
}
43+
44+
func (d *DelayedDurabilityDatabaseOption) node() {}
45+
func (d *DelayedDurabilityDatabaseOption) databaseOption() {}
46+
3847
// AlterDatabaseAddFileStatement represents ALTER DATABASE ... ADD FILE statement
3948
type AlterDatabaseAddFileStatement struct {
4049
DatabaseName *Identifier

ast/create_simple_statements.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ func (s *CreateSymmetricKeyStatement) statement() {}
8282

8383
// CreateMessageTypeStatement represents a CREATE MESSAGE TYPE statement.
8484
type CreateMessageTypeStatement struct {
85-
Name *Identifier `json:"Name,omitempty"`
85+
Name *Identifier `json:"Name,omitempty"`
86+
Owner *Identifier `json:"Owner,omitempty"`
87+
ValidationMethod string `json:"ValidationMethod,omitempty"`
88+
XmlSchemaCollectionName *SchemaObjectName `json:"XmlSchemaCollectionName,omitempty"`
8689
}
8790

8891
func (s *CreateMessageTypeStatement) node() {}

parser/marshal.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ func databaseOptionToJSON(opt ast.DatabaseOption) jsonNode {
791791
"OptionKind": o.OptionKind,
792792
"OptionState": o.OptionState,
793793
}
794+
case *ast.DelayedDurabilityDatabaseOption:
795+
return jsonNode{
796+
"$type": "DelayedDurabilityDatabaseOption",
797+
"Value": o.Value,
798+
"OptionKind": o.OptionKind,
799+
}
794800
default:
795801
return jsonNode{"$type": "UnknownDatabaseOption"}
796802
}
@@ -6113,6 +6119,15 @@ func createMessageTypeStatementToJSON(s *ast.CreateMessageTypeStatement) jsonNod
61136119
if s.Name != nil {
61146120
node["Name"] = identifierToJSON(s.Name)
61156121
}
6122+
if s.Owner != nil {
6123+
node["Owner"] = identifierToJSON(s.Owner)
6124+
}
6125+
if s.ValidationMethod != "" {
6126+
node["ValidationMethod"] = s.ValidationMethod
6127+
}
6128+
if s.XmlSchemaCollectionName != nil {
6129+
node["XmlSchemaCollectionName"] = schemaObjectNameToJSON(s.XmlSchemaCollectionName)
6130+
}
61166131
return node
61176132
}
61186133

parser/parse_ddl.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,19 @@ func (p *Parser) parseAlterDatabaseSetStatement(dbName *ast.Identifier) (*ast.Al
14601460
OptionState: capitalizeFirst(optionValue),
14611461
}
14621462
stmt.Options = append(stmt.Options, opt)
1463+
case "DELAYED_DURABILITY":
1464+
// This option uses = with DISABLED/ALLOWED/FORCED values
1465+
if p.curTok.Type != TokenEquals {
1466+
return nil, fmt.Errorf("expected = after %s, got %s", optionName, p.curTok.Literal)
1467+
}
1468+
p.nextToken()
1469+
optionValue := strings.ToUpper(p.curTok.Literal)
1470+
p.nextToken()
1471+
opt := &ast.DelayedDurabilityDatabaseOption{
1472+
OptionKind: "DelayedDurability",
1473+
Value: capitalizeFirst(optionValue),
1474+
}
1475+
stmt.Options = append(stmt.Options, opt)
14631476
default:
14641477
// Handle generic options with = syntax (e.g., OPTIMIZED_LOCKING = ON)
14651478
if p.curTok.Type == TokenEquals {

parser/parse_statements.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4622,8 +4622,52 @@ func (p *Parser) parseCreateMessageTypeStatement() (*ast.CreateMessageTypeStatem
46224622
Name: p.parseIdentifier(),
46234623
}
46244624

4625-
// Skip rest of statement
4626-
p.skipToEndOfStatement()
4625+
// Optional AUTHORIZATION
4626+
if strings.ToUpper(p.curTok.Literal) == "AUTHORIZATION" {
4627+
p.nextToken()
4628+
stmt.Owner = p.parseIdentifier()
4629+
}
4630+
4631+
// Optional VALIDATION
4632+
if strings.ToUpper(p.curTok.Literal) == "VALIDATION" {
4633+
p.nextToken()
4634+
if p.curTok.Type == TokenEquals {
4635+
p.nextToken()
4636+
}
4637+
valMethod := strings.ToUpper(p.curTok.Literal)
4638+
switch valMethod {
4639+
case "WELL_FORMED_XML":
4640+
stmt.ValidationMethod = "WellFormedXml"
4641+
p.nextToken()
4642+
case "NONE":
4643+
stmt.ValidationMethod = "None"
4644+
p.nextToken()
4645+
case "EMPTY":
4646+
stmt.ValidationMethod = "Empty"
4647+
p.nextToken()
4648+
case "VALID_XML":
4649+
stmt.ValidationMethod = "ValidXml"
4650+
p.nextToken()
4651+
// Expect WITH SCHEMA COLLECTION
4652+
if strings.ToUpper(p.curTok.Literal) == "WITH" {
4653+
p.nextToken()
4654+
if strings.ToUpper(p.curTok.Literal) == "SCHEMA" {
4655+
p.nextToken()
4656+
if strings.ToUpper(p.curTok.Literal) == "COLLECTION" {
4657+
p.nextToken()
4658+
schemaName, _ := p.parseSchemaObjectName()
4659+
stmt.XmlSchemaCollectionName = schemaName
4660+
}
4661+
}
4662+
}
4663+
}
4664+
}
4665+
4666+
// Skip optional semicolon
4667+
if p.curTok.Type == TokenSemicolon {
4668+
p.nextToken()
4669+
}
4670+
46274671
return stmt, nil
46284672
}
46294673

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"skip": false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"skip": false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"skip": false}

0 commit comments

Comments
 (0)