Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d4041d1
Add positional information to AST nodes
claude Jul 30, 2026
41c28aa
Fix span recording for optimizer hints and sort-order expressions
claude Jul 30, 2026
0d0c9dc
Fix span recording for optimizer hints, index options, call targets, …
claude Jul 30, 2026
2a7820e
Fix span recording for string/integer literals and index option loops
claude Jul 30, 2026
5823743
Fix spans for file declarations, identity options, drop elements, top…
claude Jul 30, 2026
83f7dd6
Fix spans for alter-table-add elements, inline indexes, trigger actio…
claude Jul 30, 2026
c8d68ad
Fix spans for statistics options, permissions, workload params, pseud…
claude Jul 30, 2026
ce54296
Fix spans for constraints, stats options, system versioning, promoted…
claude Jul 30, 2026
452f369
Fix spans for view options, constraint index options, xml index paths
claude Jul 30, 2026
b4a9928
Fix spans for inline indexes, output clauses, constraint columns
claude Jul 30, 2026
650d84a
Fix spans for bulk/external-table/session options and principals
claude Jul 30, 2026
fccbd72
Fix spans for procedure params, principals, session options, use fede…
claude Jul 30, 2026
9e6f285
Fix spans for audit parts/targets, permissions, principal options
claude Jul 30, 2026
675ac1e
Fix spans for session options, user options, try/catch lists, audit t…
claude Jul 30, 2026
069cbed
Fix spans for partition specifiers, drop index clauses, contract mess…
claude Jul 30, 2026
aea619e
Fix spans for database options, filegroups, within-group, postfix calls
claude Jul 30, 2026
d89e49c
Fix spans for break/continue, inline index defs, UDT call chains
claude Jul 30, 2026
fc6e142
Fix spans for masked columns, function options, devices, special calls
claude Jul 30, 2026
9dc4327
Fix spans for function/procedure/user options and execute-as clauses
claude Jul 30, 2026
9f77050
Fix spans for when clauses, assembly options, text pointers, execute-as
claude Jul 30, 2026
98bf88f
Fix spans for database options, config options, lock wait and storage…
claude Jul 30, 2026
8a8b4cf
Fix spans for cursor defs, sequence/key/backup options, fragment embeds
claude Jul 30, 2026
35c0442
Fix spans for user/queue/role options, event scopes, trigger objects
claude Jul 30, 2026
a53ee06
Fix spans for merge specs, xml namespaces, TVF returns, execute-as op…
claude Jul 30, 2026
ea835d4
Fix spans for merge, execute specs/contexts, string lists, paren exprs
claude Jul 30, 2026
fe285ac
Fix graph match spans with pin mechanism, CTAS select, pseudo columns
claude Jul 30, 2026
bd164e3
Fix spans for fulltext options, graph constraints, when clauses
claude Jul 30, 2026
92e24b7
Fix spans for restore options, audit maxsize, fulltext actions
claude Jul 30, 2026
1f5674e
Fix spans for column defs (hidden/encrypted), storage opts, window fr…
claude Jul 31, 2026
7e95cc6
Fix spans for nullable, semantic columns, row values, subqueries
claude Jul 31, 2026
31ceaff
Fix spans for statement lists, TVF body constraints, atomic blocks
claude Jul 31, 2026
f849a23
Fix spans for cursor ids, fetch types, backup file info, mutator calls
claude Jul 31, 2026
75917af
Fix spans for view options, retention periods, system versioning
claude Jul 31, 2026
c747cca
Fix spans for audit specs, external file formats, view options
claude Jul 31, 2026
16e3577
Fix spans for binary query exprs, end conversation statements
claude Jul 31, 2026
a7379e0
Fix invalid UTF-8 decoding, double precision spans
claude Jul 31, 2026
93dfce2
Fix spans for switch options, security targets, user login options
claude Jul 31, 2026
6125da6
Fix spans for query store options, database termination
claude Jul 31, 2026
2b0b049
Fix spans for partner/witness/parameterization/page verify options
claude Jul 31, 2026
8d58fb5
Fix spans for inline options, function body trailing semicolons
claude Jul 31, 2026
41f44a0
Fix spans for copy options, dbcc, json key values, default literals
claude Jul 31, 2026
5d622a4
Fix spans for certificates, service contracts, endpoint affinity
claude Jul 31, 2026
f53518f
Fix spans for endpoints, soap methods
claude Jul 31, 2026
45aeded
Fix spans for endpoint protocol/payload options, IPv4 octets
claude Jul 31, 2026
01afed6
Fix spans for exec contexts, user login, updatetext timestamps
claude Jul 31, 2026
e545ef3
Fix spans for login sources and options
claude Jul 31, 2026
20435fa
Fix spans for resource pool params, delayed durability
claude Jul 31, 2026
8634dc4
Fix spans for RDA/table dir/cursor default/recovery options
claude Jul 31, 2026
f1668d9
Fix spans for EXECUTE result sets, execute context, copy options
claude Jul 31, 2026
cdd0524
Fix spans for availability groups, spatial index, assembly, trigger s…
claude Jul 31, 2026
ed1ce85
Fix spans for softnuma, key options, broker priority, dialog, replica…
claude Jul 31, 2026
aa1cb6d
Fix spans for stoplist, route, encryption key values, json key values…
claude Jul 31, 2026
9c6bdfc
Fix spans for fulltext columns, optimizer hints, temporal clause, ope…
claude Jul 31, 2026
9a76c6e
Fix spans for ledger, table compression, azure database options
claude Jul 31, 2026
599347b
Fix spans for server configuration diagnostics/failover/hadr/buffer p…
claude Jul 31, 2026
556fe5a
Fix spans for backup encryption, filestream, security predicate actions
claude Jul 31, 2026
530d205
Fix spans for xml for-clause, grouping sets, window clause, dbcc lite…
claude Jul 31, 2026
e6b57eb
Fix spans for generic config primary, transform noise words, execute …
claude Jul 31, 2026
dffd029
Fix spans for opendatasource, cursor def, ipv4 octets, updatetext binary
claude Jul 31, 2026
0533404
Fix spans for commit work, cursor id, udt call with leading dot, endp…
claude Jul 31, 2026
3d44289
Fix spans for implicit execute statements and workload classifier imp…
claude Jul 31, 2026
32cda07
Fix spans for implicit exec, classifier importance, query parenthesis…
claude Jul 31, 2026
018536c
Fix rollback work span, connection user type, sqlcmd database identifier
claude Jul 31, 2026
2bb035d
Fix spans for table hints, lone CR line counting, rollback work
claude Jul 31, 2026
f588e10
Fix spans for repeated semicolons, filetable null case, RETURN(WITH .…
claude Jul 31, 2026
ca04fbe
Fix spans for adhoc table refs, wildcard fulltext columns, inline ref…
claude Jul 31, 2026
dc8a03e
Fix spans for order bulk insert and cosmos options
claude Jul 31, 2026
55167c3
Fix spans for pivoted table refs, FOR XML in derived tables
claude Jul 31, 2026
ccb0e3c
Fix spans for filegroup definitions, unlimited maxsize
claude Jul 31, 2026
266d434
Fix spans for exists predicate, fulltext pseudo columns, comparison s…
claude Jul 31, 2026
6cd339a
Fix spans for single-column fulltext predicates, IN subqueries
claude Jul 31, 2026
9b134be
Fix spans for graph shortest path predicates, quantifiers, last node …
claude Jul 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions TsqlAstParser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ class AstToJsonConverter
["$type"] = node.GetType().Name
};

// Emit positional information for fragments that have real tokens.
// Synthesized fragments (no source tokens) have StartOffset == -1.
if (node.StartOffset >= 0)
{
result["StartOffset"] = node.StartOffset;
result["FragmentLength"] = node.FragmentLength;
result["StartLine"] = node.StartLine;
result["StartColumn"] = node.StartColumn;
}

var type = node.GetType();
var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

Expand Down
2 changes: 2 additions & 0 deletions ast/adhoc_table_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ast
// Syntax: OPENDATASOURCE('provider', 'connstr').'object'
// Uses AdHocDataSource from execute_statement.go
type AdHocTableReference struct {
Fragment
DataSource *AdHocDataSource `json:"DataSource,omitempty"`
Object *SchemaObjectNameOrValueExpression `json:"Object,omitempty"`
Alias *Identifier `json:"Alias,omitempty"`
Expand All @@ -15,6 +16,7 @@ func (*AdHocTableReference) tableReference() {}

// SchemaObjectNameOrValueExpression represents either a schema object name or a value expression
type SchemaObjectNameOrValueExpression struct {
Fragment
SchemaObjectName *SchemaObjectName `json:"SchemaObjectName,omitempty"`
ValueExpression ScalarExpression `json:"ValueExpression,omitempty"`
}
1 change: 1 addition & 0 deletions ast/alter_authorization_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ast

// AlterAuthorizationStatement represents an ALTER AUTHORIZATION statement
type AlterAuthorizationStatement struct {
Fragment
SecurityTargetObject *SecurityTargetObject
ToSchemaOwner bool
PrincipalName *Identifier
Expand Down
16 changes: 10 additions & 6 deletions ast/alter_availability_group_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package ast

// AlterAvailabilityGroupStatement represents ALTER AVAILABILITY GROUP statement
type AlterAvailabilityGroupStatement struct {
Name *Identifier
StatementType string // "Action", "AddDatabase", "RemoveDatabase", "AddReplica", "ModifyReplica", "RemoveReplica", "Set"
Action AvailabilityGroupAction
Databases []*Identifier
Replicas []*AvailabilityReplica
Options []AvailabilityGroupOption
Fragment
Name *Identifier
StatementType string // "Action", "AddDatabase", "RemoveDatabase", "AddReplica", "ModifyReplica", "RemoveReplica", "Set"
Action AvailabilityGroupAction
Databases []*Identifier
Replicas []*AvailabilityReplica
Options []AvailabilityGroupOption
}

func (s *AlterAvailabilityGroupStatement) node() {}
Expand All @@ -21,6 +22,7 @@ type AvailabilityGroupAction interface {

// AlterAvailabilityGroupAction represents simple actions like JOIN, ONLINE, OFFLINE
type AlterAvailabilityGroupAction struct {
Fragment
ActionType string // "Join", "ForceFailoverAllowDataLoss", "Online", "Offline"
}

Expand All @@ -29,6 +31,7 @@ func (a *AlterAvailabilityGroupAction) availabilityGroupAction() {}

// AlterAvailabilityGroupFailoverAction represents FAILOVER action with options
type AlterAvailabilityGroupFailoverAction struct {
Fragment
ActionType string // "Failover"
Options []*AlterAvailabilityGroupFailoverOption
}
Expand All @@ -38,6 +41,7 @@ func (a *AlterAvailabilityGroupFailoverAction) availabilityGroupAction() {}

// AlterAvailabilityGroupFailoverOption represents an option for failover action
type AlterAvailabilityGroupFailoverOption struct {
Fragment
OptionKind string // "Target"
Value ScalarExpression // StringLiteral for target server
}
Expand Down
1 change: 1 addition & 0 deletions ast/alter_credential_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ast

// AlterCredentialStatement represents an ALTER CREDENTIAL statement.
type AlterCredentialStatement struct {
Fragment
Name *Identifier
Identity ScalarExpression
Secret ScalarExpression
Expand Down
Loading
Loading