Skip to content

Commit 92b3e5c

Browse files
authored
Add support for multiple statement types and enable more tests (#9)
1 parent 0bab899 commit 92b3e5c

File tree

37 files changed

+4618
-1709
lines changed

37 files changed

+4618
-1709
lines changed

ast/alter_function_statement.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package ast
2+
3+
// AlterFunctionStatement represents an ALTER FUNCTION statement
4+
type AlterFunctionStatement struct {
5+
Name *SchemaObjectName
6+
Parameters []*ProcedureParameter
7+
ReturnType FunctionReturnType
8+
Options []*FunctionOption
9+
StatementList *StatementList
10+
}
11+
12+
func (s *AlterFunctionStatement) statement() {}
13+
func (s *AlterFunctionStatement) node() {}
14+
15+
// FunctionReturnType is an interface for function return types
16+
type FunctionReturnType interface {
17+
functionReturnTypeNode()
18+
}
19+
20+
// ScalarFunctionReturnType represents a scalar function return type
21+
type ScalarFunctionReturnType struct {
22+
DataType DataTypeReference
23+
}
24+
25+
func (r *ScalarFunctionReturnType) functionReturnTypeNode() {}
26+
27+
// TableValuedFunctionReturnType represents a table-valued function return type
28+
type TableValuedFunctionReturnType struct {
29+
// Simplified - will be expanded later
30+
}
31+
32+
func (r *TableValuedFunctionReturnType) functionReturnTypeNode() {}
33+
34+
// SelectFunctionReturnType represents a SELECT function return type
35+
type SelectFunctionReturnType struct {
36+
// Simplified - will be expanded later
37+
}
38+
39+
func (r *SelectFunctionReturnType) functionReturnTypeNode() {}
40+
41+
// FunctionOption represents a function option
42+
type FunctionOption struct {
43+
OptionKind string
44+
OptionState string
45+
}

ast/alter_index_statement.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ast
2+
3+
// AlterIndexStatement represents ALTER INDEX statement
4+
type AlterIndexStatement struct {
5+
Name *Identifier
6+
All bool
7+
OnName *SchemaObjectName
8+
AlterIndexType string // "Rebuild", "Reorganize", "Disable", "Set", etc.
9+
Partition *PartitionSpecifier
10+
IndexOptions []IndexOption
11+
}
12+
13+
func (s *AlterIndexStatement) statement() {}
14+
func (s *AlterIndexStatement) node() {}
15+
16+
// PartitionSpecifier represents a partition specifier
17+
type PartitionSpecifier struct {
18+
All bool
19+
Number ScalarExpression
20+
Numbers []ScalarExpression
21+
}
22+
23+
func (p *PartitionSpecifier) node() {}

ast/alter_table_alter_index_statement.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ type AlterTableAlterIndexStatement struct {
1111
func (a *AlterTableAlterIndexStatement) node() {}
1212
func (a *AlterTableAlterIndexStatement) statement() {}
1313

14+
// IndexOption is an interface for index options
15+
type IndexOption interface {
16+
Node
17+
indexOption()
18+
}
19+
20+
// IndexStateOption represents an ON/OFF index option
21+
type IndexStateOption struct {
22+
OptionKind string // "PadIndex", "SortInTempDB", "IgnoreDupKey", etc.
23+
OptionState string // "On", "Off"
24+
}
25+
26+
func (o *IndexStateOption) indexOption() {}
27+
func (o *IndexStateOption) node() {}
28+
1429
// IndexExpressionOption represents an index option with expression value
1530
type IndexExpressionOption struct {
1631
OptionKind string
1732
Expression ScalarExpression
1833
}
1934

20-
func (i *IndexExpressionOption) node() {}
35+
func (i *IndexExpressionOption) indexOption() {}
36+
func (i *IndexExpressionOption) node() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ast
2+
3+
// AlterTableConstraintModificationStatement represents ALTER TABLE ... CHECK/NOCHECK CONSTRAINT
4+
type AlterTableConstraintModificationStatement struct {
5+
SchemaObjectName *SchemaObjectName
6+
ExistingRowsCheckEnforcement string // "NotSpecified", "Check", "NoCheck"
7+
ConstraintEnforcement string // "Check", "NoCheck"
8+
All bool
9+
ConstraintNames []*Identifier
10+
}
11+
12+
func (s *AlterTableConstraintModificationStatement) statement() {}
13+
func (s *AlterTableConstraintModificationStatement) node() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package ast
2+
3+
// AlterTableSwitchStatement represents ALTER TABLE ... SWITCH
4+
type AlterTableSwitchStatement struct {
5+
SchemaObjectName *SchemaObjectName
6+
SourcePartition ScalarExpression
7+
TargetTable *SchemaObjectName
8+
TargetPartition ScalarExpression
9+
Options []TableSwitchOption
10+
LowPriorityLockWait *LowPriorityLockWait
11+
}
12+
13+
func (s *AlterTableSwitchStatement) statement() {}
14+
func (s *AlterTableSwitchStatement) node() {}
15+
16+
// TableSwitchOption is an interface for switch options
17+
type TableSwitchOption interface {
18+
Node
19+
tableSwitchOption()
20+
}
21+
22+
// TruncateTargetTableSwitchOption represents TRUNCATE_TARGET option
23+
type TruncateTargetTableSwitchOption struct {
24+
TruncateTarget bool
25+
OptionKind string
26+
}
27+
28+
func (o *TruncateTargetTableSwitchOption) tableSwitchOption() {}
29+
func (o *TruncateTargetTableSwitchOption) node() {}
30+
31+
// LowPriorityLockWait represents LOW_PRIORITY_LOCK_WAIT option
32+
type LowPriorityLockWait struct {
33+
MaxDuration ScalarExpression
34+
MaxDurationUnit string // "MINUTES", "SECONDS"
35+
AfterWaitAbort string // "NONE", "SELF", "BLOCKERS"
36+
}
37+
38+
func (l *LowPriorityLockWait) node() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ast
2+
3+
// AlterTableTriggerModificationStatement represents ALTER TABLE ... ENABLE/DISABLE TRIGGER
4+
type AlterTableTriggerModificationStatement struct {
5+
SchemaObjectName *SchemaObjectName
6+
TriggerEnforcement string // "Enable" or "Disable"
7+
All bool
8+
TriggerNames []*Identifier
9+
}
10+
11+
func (s *AlterTableTriggerModificationStatement) statement() {}
12+
func (s *AlterTableTriggerModificationStatement) node() {}

ast/alter_trigger_statement.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ast
2+
3+
// AlterTriggerStatement represents an ALTER TRIGGER statement
4+
type AlterTriggerStatement struct {
5+
Name *SchemaObjectName
6+
TriggerObject *TriggerObject
7+
TriggerType string // "For", "After", "InsteadOf"
8+
TriggerActions []*TriggerAction
9+
Options []*TriggerOption
10+
WithAppend bool
11+
IsNotForReplication bool
12+
MethodSpecifier *MethodSpecifier
13+
StatementList *StatementList
14+
}
15+
16+
func (s *AlterTriggerStatement) statement() {}
17+
func (s *AlterTriggerStatement) node() {}
18+
19+
// TriggerObject represents the object a trigger is associated with
20+
type TriggerObject struct {
21+
Name *SchemaObjectName
22+
TriggerScope string // "Normal", "AllServer", "Database"
23+
}
24+
25+
// TriggerAction represents a trigger action
26+
type TriggerAction struct {
27+
TriggerActionType string // "Insert", "Update", "Delete", "Event", etc.
28+
EventTypeGroup *EventTypeContainer // For database/server events
29+
}
30+
31+
// TriggerOption represents a trigger option
32+
type TriggerOption struct {
33+
OptionKind string
34+
OptionState string
35+
}
36+
37+
// MethodSpecifier represents a CLR method specifier
38+
type MethodSpecifier struct {
39+
AssemblyName *Identifier
40+
ClassName *Identifier
41+
MethodName *Identifier
42+
}

ast/create_aggregate_statement.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ast
2+
3+
// CreateAggregateStatement represents a CREATE AGGREGATE statement
4+
type CreateAggregateStatement struct {
5+
Name *SchemaObjectName
6+
Parameters []*ProcedureParameter
7+
ReturnType DataTypeReference
8+
AssemblyName *AssemblyName
9+
}
10+
11+
func (s *CreateAggregateStatement) statement() {}
12+
func (s *CreateAggregateStatement) node() {}
13+
14+
// AssemblyName represents an assembly name reference
15+
type AssemblyName struct {
16+
Name *Identifier
17+
ClassName *Identifier
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ast
2+
3+
// CreateColumnStoreIndexStatement represents a CREATE COLUMNSTORE INDEX statement
4+
type CreateColumnStoreIndexStatement struct {
5+
Name *Identifier
6+
Clustered bool
7+
OnName *SchemaObjectName
8+
Columns []*ColumnReferenceExpression
9+
OrderedColumns []*ColumnReferenceExpression
10+
IndexOptions []IndexOption
11+
FilterClause ScalarExpression
12+
OnPartition *PartitionSpecifier
13+
}
14+
15+
func (s *CreateColumnStoreIndexStatement) statement() {}
16+
func (s *CreateColumnStoreIndexStatement) node() {}

ast/create_trigger_statement.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ast
2+
3+
// CreateTriggerStatement represents a CREATE TRIGGER statement
4+
type CreateTriggerStatement struct {
5+
Name *SchemaObjectName
6+
TriggerObject *TriggerObject
7+
TriggerType string // "For", "After", "InsteadOf"
8+
TriggerActions []*TriggerAction
9+
Options []*TriggerOption
10+
WithAppend bool
11+
IsNotForReplication bool
12+
MethodSpecifier *MethodSpecifier
13+
StatementList *StatementList
14+
}
15+
16+
func (s *CreateTriggerStatement) statement() {}
17+
func (s *CreateTriggerStatement) node() {}
18+
19+
// EventTypeContainer represents an event type container
20+
type EventTypeContainer struct {
21+
EventType string
22+
}

0 commit comments

Comments
 (0)