Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
98179f2
Add FileGroupDefinition parsing for CREATE DATABASE ON clause
claude Dec 31, 2025
953009d
Add semicolon skipping in trigger/try-catch statement bodies
claude Dec 31, 2025
2c93200
Add SET ROWCOUNT, SET OFFSETS, and multi-option SET parsing
claude Dec 31, 2025
4fbe2ea
Add CREATE DATABASE CONTAINMENT and WITH options parsing
claude Dec 31, 2025
e08d5e9
Add CREATE/ALTER SERVICE full parsing support
claude Dec 31, 2025
f8fb162
Add CREATE/DROP SYMMETRIC KEY full parsing support
claude Dec 31, 2025
182e749
Add CTE (Common Table Expression) parsing support
claude Dec 31, 2025
34d7753
Add support for space-separated table hints parsing
claude Dec 31, 2025
60052b4
Add support for space-separated table hints and old-style hint syntax
claude Dec 31, 2025
6bacbdf
Add full ALTER ENDPOINT parsing with State, Affinity, Protocol, and P…
claude Dec 31, 2025
a8a51c6
Add CREATE/ALTER USER WITH options parsing support
claude Dec 31, 2025
e1514d0
Add OPEN SYMMETRIC KEY DECRYPTION BY clause parsing
claude Dec 31, 2025
445410b
Add WITHIN GROUP clause parsing for ordered set aggregate functions
claude Dec 31, 2025
f8eadf7
Add WITH RESULT SETS and WITH RECOMPILE for EXECUTE statements
claude Dec 31, 2025
89cccac
Add USE HINT and NO_PERFORMANCE_SPOOL optimizer hint parsing support
claude Dec 31, 2025
14bfcdd
Add CREATE REMOTE SERVICE BINDING parsing with TO SERVICE and WITH op…
claude Dec 31, 2025
5f9616c
Add ALTER DATABASE ADD FILE parsing with file declarations and options
claude Dec 31, 2025
59f8528
Add sorting for SET STATISTICS options to match ScriptDom order
claude Dec 31, 2025
93fda19
Fix RECEIVE statement WHERE clause and use XmlDataTypeReference for X…
claude Dec 31, 2025
9fa366e
Add NULL/NOT NULL constraint parsing for CREATE AGGREGATE parameters
claude Dec 31, 2025
9bb9016
Add CREATE STATISTICS filter predicate and STATS_STREAM option parsing
claude Dec 31, 2025
b091e21
Add CREATE COLUMN MASTER KEY statement parsing support
claude Dec 31, 2025
7fb18c5
Add CREATE TABLE WITH clause and FILESTREAM_ON parsing support
claude Dec 31, 2025
2186056
Add CREATE/ALTER ROUTE statement option parsing
claude Dec 31, 2025
746b30e
Add CREATE PROCEDURE WITH clause and EXTERNAL NAME parsing
claude Dec 31, 2025
5081feb
Add DROP INDEX WITH clause options parsing
claude Dec 31, 2025
9561bbd
Add COLLATE clause parsing for column definitions
claude Dec 31, 2025
5519571
Add scalar subquery parsing in boolean expressions
claude Dec 31, 2025
f8f6c5e
Enable BaselinesCommon_ReturnStatementTests
claude Dec 31, 2025
7828673
Add ChildObjectName and BackwardsCompatibleDropIndexClause support
claude Dec 31, 2025
0e4c387
Add NOT ENFORCED constraint support and fix TriggerScope
claude Dec 31, 2025
8cfbb3b
Enable DropStatementsTests (auto-enabled via check-todo)
claude Dec 31, 2025
165838e
Add CREATE OR ALTER FUNCTION support and INLINE function option
claude Dec 31, 2025
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
6 changes: 5 additions & 1 deletion ast/alter_database_set_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func (l *LiteralDatabaseOption) createDatabaseOption() {}

// AlterDatabaseAddFileStatement represents ALTER DATABASE ... ADD FILE statement
type AlterDatabaseAddFileStatement struct {
DatabaseName *Identifier
DatabaseName *Identifier
FileDeclarations []*FileDeclaration
FileGroup *Identifier
IsLog bool
UseCurrent bool
}

func (a *AlterDatabaseAddFileStatement) node() {}
Expand Down
39 changes: 34 additions & 5 deletions ast/alter_function_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type AlterFunctionStatement struct {
Name *SchemaObjectName
Parameters []*ProcedureParameter
ReturnType FunctionReturnType
Options []*FunctionOption
Options []FunctionOptionBase
StatementList *StatementList
}

Expand All @@ -17,7 +17,7 @@ type CreateFunctionStatement struct {
Name *SchemaObjectName
Parameters []*ProcedureParameter
ReturnType FunctionReturnType
Options []*FunctionOption
Options []FunctionOptionBase
StatementList *StatementList
}

Expand Down Expand Up @@ -50,8 +50,37 @@ type SelectFunctionReturnType struct {

func (r *SelectFunctionReturnType) functionReturnTypeNode() {}

// FunctionOption represents a function option
// FunctionOptionBase is an interface for function options
type FunctionOptionBase interface {
Node
functionOption()
}

// FunctionOption represents a function option (like ENCRYPTION, SCHEMABINDING)
type FunctionOption struct {
OptionKind string
OptionState string
OptionKind string
}

func (o *FunctionOption) node() {}
func (o *FunctionOption) functionOption() {}

// InlineFunctionOption represents an INLINE function option
type InlineFunctionOption struct {
OptionKind string // "Inline"
OptionState string // "On", "Off"
}

func (o *InlineFunctionOption) node() {}
func (o *InlineFunctionOption) functionOption() {}

// CreateOrAlterFunctionStatement represents a CREATE OR ALTER FUNCTION statement
type CreateOrAlterFunctionStatement struct {
Name *SchemaObjectName
Parameters []*ProcedureParameter
ReturnType FunctionReturnType
Options []FunctionOptionBase
StatementList *StatementList
}

func (s *CreateOrAlterFunctionStatement) statement() {}
func (s *CreateOrAlterFunctionStatement) node() {}
57 changes: 54 additions & 3 deletions ast/alter_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package ast

// AlterRouteStatement represents an ALTER ROUTE statement.
type AlterRouteStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
RouteOptions []*RouteOption `json:"RouteOptions,omitempty"`
}

func (s *AlterRouteStatement) node() {}
Expand All @@ -18,15 +19,65 @@ func (s *AlterAssemblyStatement) statement() {}

// AlterEndpointStatement represents an ALTER ENDPOINT statement.
type AlterEndpointStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
State string `json:"State,omitempty"` // Started, Disabled, NotSpecified
Affinity *EndpointAffinity `json:"Affinity,omitempty"`
Protocol string `json:"Protocol,omitempty"` // None, Tcp, Http
ProtocolOptions []EndpointProtocolOption `json:"ProtocolOptions,omitempty"`
EndpointType string `json:"EndpointType,omitempty"` // NotSpecified, Soap, ServiceBroker, etc.
PayloadOptions []PayloadOption `json:"PayloadOptions,omitempty"`
}

func (s *AlterEndpointStatement) node() {}
func (s *AlterEndpointStatement) statement() {}

// EndpointAffinity represents the affinity setting for an endpoint.
type EndpointAffinity struct {
Kind string `json:"Kind,omitempty"` // None, Admin, Integer
Value *IntegerLiteral `json:"Value,omitempty"`
}

func (e *EndpointAffinity) node() {}

// EndpointProtocolOption is an interface for endpoint protocol options.
type EndpointProtocolOption interface {
Node
endpointProtocolOption()
}

// LiteralEndpointProtocolOption represents a literal endpoint protocol option.
type LiteralEndpointProtocolOption struct {
Value ScalarExpression `json:"Value,omitempty"`
Kind string `json:"Kind,omitempty"` // TcpListenerPort, HttpListenerPort, etc.
}

func (l *LiteralEndpointProtocolOption) node() {}
func (l *LiteralEndpointProtocolOption) endpointProtocolOption() {}

// PayloadOption is an interface for endpoint payload options.
type PayloadOption interface {
Node
payloadOption()
}

// SoapMethod represents a SOAP web method option.
type SoapMethod struct {
Alias *StringLiteral `json:"Alias,omitempty"`
Action string `json:"Action,omitempty"` // Add, Alter, Drop
Name *StringLiteral `json:"Name,omitempty"`
Format string `json:"Format,omitempty"` // NotSpecified, AllResults, RowsetsOnly, None
Schema string `json:"Schema,omitempty"` // NotSpecified, Default, None, Standard
Kind string `json:"Kind,omitempty"` // None, WebMethod
}

func (s *SoapMethod) node() {}
func (s *SoapMethod) payloadOption() {}

// AlterServiceStatement represents an ALTER SERVICE statement.
type AlterServiceStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
QueueName *SchemaObjectName `json:"QueueName,omitempty"`
ServiceContracts []*ServiceContract `json:"ServiceContracts,omitempty"`
}

func (s *AlterServiceStatement) node() {}
Expand Down
6 changes: 4 additions & 2 deletions ast/alter_trigger_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ func (o *TriggerOption) triggerOption() {}

// ExecuteAsClause represents an EXECUTE AS clause
type ExecuteAsClause struct {
ExecuteAsOption string // Caller, Self, Owner, or specific user
Principal ScalarExpression
ExecuteAsOption string // Caller, Self, Owner, String
Literal *StringLiteral // Used when ExecuteAsOption is "String"
}

func (e *ExecuteAsClause) node() {}

// ExecuteAsTriggerOption represents an EXECUTE AS trigger option
type ExecuteAsTriggerOption struct {
OptionKind string // "ExecuteAsClause"
Expand Down
4 changes: 2 additions & 2 deletions ast/alter_user_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package ast

// AlterUserStatement represents an ALTER USER statement.
type AlterUserStatement struct {
Name *Identifier `json:"Name,omitempty"`
Options []UserOption `json:"Options,omitempty"`
Name *Identifier `json:"Name,omitempty"`
UserOptions []UserOption `json:"UserOptions,omitempty"`
}

func (s *AlterUserStatement) node() {}
Expand Down
51 changes: 51 additions & 0 deletions ast/column_master_key_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package ast

// CreateColumnMasterKeyStatement represents a CREATE COLUMN MASTER KEY statement.
type CreateColumnMasterKeyStatement struct {
Name *Identifier
Parameters []ColumnMasterKeyParameter
}

func (c *CreateColumnMasterKeyStatement) node() {}
func (c *CreateColumnMasterKeyStatement) statement() {}

// ColumnMasterKeyParameter is an interface for column master key parameters.
type ColumnMasterKeyParameter interface {
Node
columnMasterKeyParameter()
}

// ColumnMasterKeyStoreProviderNameParameter represents KEY_STORE_PROVIDER_NAME parameter.
type ColumnMasterKeyStoreProviderNameParameter struct {
Name ScalarExpression
ParameterKind string
}

func (c *ColumnMasterKeyStoreProviderNameParameter) node() {}
func (c *ColumnMasterKeyStoreProviderNameParameter) columnMasterKeyParameter() {}

// ColumnMasterKeyPathParameter represents KEY_PATH parameter.
type ColumnMasterKeyPathParameter struct {
Path ScalarExpression
ParameterKind string
}

func (c *ColumnMasterKeyPathParameter) node() {}
func (c *ColumnMasterKeyPathParameter) columnMasterKeyParameter() {}

// ColumnMasterKeyEnclaveComputationsParameter represents ENCLAVE_COMPUTATIONS parameter.
type ColumnMasterKeyEnclaveComputationsParameter struct {
Signature ScalarExpression
ParameterKind string
}

func (c *ColumnMasterKeyEnclaveComputationsParameter) node() {}
func (c *ColumnMasterKeyEnclaveComputationsParameter) columnMasterKeyParameter() {}

// DropColumnMasterKeyStatement represents a DROP COLUMN MASTER KEY statement.
type DropColumnMasterKeyStatement struct {
Name *Identifier
}

func (d *DropColumnMasterKeyStatement) node() {}
func (d *DropColumnMasterKeyStatement) statement() {}
25 changes: 25 additions & 0 deletions ast/create_procedure_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type CreateProcedureStatement struct {
Parameters []*ProcedureParameter
StatementList *StatementList
IsForReplication bool
Options []ProcedureOptionBase
MethodSpecifier *MethodSpecifier
}

func (c *CreateProcedureStatement) node() {}
Expand All @@ -22,3 +24,26 @@ type ProcedureParameter struct {
}

func (p *ProcedureParameter) node() {}

// ProcedureOptionBase is the interface for procedure options.
type ProcedureOptionBase interface {
Node
procedureOption()
}

// ProcedureOption represents a simple procedure option like RECOMPILE or ENCRYPTION.
type ProcedureOption struct {
OptionKind string // Recompile, Encryption
}

func (p *ProcedureOption) node() {}
func (p *ProcedureOption) procedureOption() {}

// ExecuteAsProcedureOption represents an EXECUTE AS option for a procedure.
type ExecuteAsProcedureOption struct {
ExecuteAs *ExecuteAsClause
OptionKind string // ExecuteAs
}

func (e *ExecuteAsProcedureOption) node() {}
func (e *ExecuteAsProcedureOption) procedureOption() {}
74 changes: 66 additions & 8 deletions ast/create_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ package ast

// CreateDatabaseStatement represents a CREATE DATABASE statement.
type CreateDatabaseStatement struct {
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
Options []CreateDatabaseOption `json:"Options,omitempty"`
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
CopyOf *MultiPartIdentifier `json:"CopyOf,omitempty"` // For AS COPY OF syntax
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
Options []CreateDatabaseOption `json:"Options,omitempty"`
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
CopyOf *MultiPartIdentifier `json:"CopyOf,omitempty"` // For AS COPY OF syntax
FileGroups []*FileGroupDefinition `json:"FileGroups,omitempty"`
LogOn []*FileDeclaration `json:"LogOn,omitempty"`
Collation *Identifier `json:"Collation,omitempty"`
Containment *ContainmentDatabaseOption `json:"Containment,omitempty"`
}

// ContainmentDatabaseOption represents CONTAINMENT = NONE/PARTIAL
type ContainmentDatabaseOption struct {
Value string // "None" or "Partial"
OptionKind string // Always "Containment"
}

func (c *ContainmentDatabaseOption) node() {}
func (c *ContainmentDatabaseOption) createDatabaseOption() {}

func (s *CreateDatabaseStatement) node() {}
func (s *CreateDatabaseStatement) statement() {}

Expand All @@ -19,9 +32,20 @@ type CreateLoginStatement struct {
func (s *CreateLoginStatement) node() {}
func (s *CreateLoginStatement) statement() {}

// ServiceContract represents a contract in CREATE/ALTER SERVICE.
type ServiceContract struct {
Name *Identifier `json:"Name,omitempty"`
Action string `json:"Action,omitempty"` // "Add", "Drop", "None"
}

func (s *ServiceContract) node() {}

// CreateServiceStatement represents a CREATE SERVICE statement.
type CreateServiceStatement struct {
Name *Identifier `json:"Name,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
Name *Identifier `json:"Name,omitempty"`
QueueName *SchemaObjectName `json:"QueueName,omitempty"`
ServiceContracts []*ServiceContract `json:"ServiceContracts,omitempty"`
}

func (s *CreateServiceStatement) node() {}
Expand Down Expand Up @@ -61,12 +85,22 @@ func (s *CreateQueueStatement) statement() {}

// CreateRouteStatement represents a CREATE ROUTE statement.
type CreateRouteStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
RouteOptions []*RouteOption `json:"RouteOptions,omitempty"`
}

func (s *CreateRouteStatement) node() {}
func (s *CreateRouteStatement) statement() {}

// RouteOption represents an option in CREATE/ALTER ROUTE statement.
type RouteOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Literal ScalarExpression `json:"Literal,omitempty"`
}

func (r *RouteOption) node() {}

// CreateEndpointStatement represents a CREATE ENDPOINT statement.
type CreateEndpointStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down Expand Up @@ -150,14 +184,36 @@ type CreationDispositionKeyOption struct {
func (c *CreationDispositionKeyOption) node() {}
func (c *CreationDispositionKeyOption) keyOption() {}

// CryptoMechanism represents an encryption mechanism (CERTIFICATE, KEY, PASSWORD, etc.)
type CryptoMechanism struct {
CryptoMechanismType string `json:"CryptoMechanismType,omitempty"` // "Certificate", "SymmetricKey", "AsymmetricKey", "Password"
Identifier *Identifier `json:"Identifier,omitempty"`
PasswordOrSignature ScalarExpression `json:"PasswordOrSignature,omitempty"`
}

func (c *CryptoMechanism) node() {}

// CreateSymmetricKeyStatement represents a CREATE SYMMETRIC KEY statement.
type CreateSymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
KeyOptions []KeyOption `json:"KeyOptions,omitempty"`
Provider *Identifier `json:"Provider,omitempty"`
Name *Identifier `json:"Name,omitempty"`
EncryptingMechanisms []*CryptoMechanism `json:"EncryptingMechanisms,omitempty"`
}

func (s *CreateSymmetricKeyStatement) node() {}
func (s *CreateSymmetricKeyStatement) statement() {}

// DropSymmetricKeyStatement represents a DROP SYMMETRIC KEY statement.
type DropSymmetricKeyStatement struct {
RemoveProviderKey bool `json:"RemoveProviderKey,omitempty"`
Name *Identifier `json:"Name,omitempty"`
IsIfExists bool `json:"IsIfExists"`
}

func (s *DropSymmetricKeyStatement) node() {}
func (s *DropSymmetricKeyStatement) statement() {}

// CreateMessageTypeStatement represents a CREATE MESSAGE TYPE statement.
type CreateMessageTypeStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand All @@ -171,7 +227,9 @@ func (s *CreateMessageTypeStatement) statement() {}

// CreateRemoteServiceBindingStatement represents a CREATE REMOTE SERVICE BINDING statement.
type CreateRemoteServiceBindingStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Service ScalarExpression `json:"Service,omitempty"`
Options []RemoteServiceBindingOption `json:"Options,omitempty"`
}

func (s *CreateRemoteServiceBindingStatement) node() {}
Expand Down
Loading
Loading