MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestQualifiedIdentifierPosition

Function TestQualifiedIdentifierPosition

pkg/sql/ast/positions_test.go:200–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestQualifiedIdentifierPosition(t *testing.T) {
201 tree := parseWithPositions(t, "SELECT u.id FROM users u")
202
203 sel := tree.Statements[0].(*ast.SelectStatement)
204
205 if len(sel.Columns) == 0 {
206 t.Fatal("expected at least 1 column")
207 }
208
209 ident, ok := sel.Columns[0].(*ast.Identifier)
210 if !ok {
211 t.Fatalf("expected *ast.Identifier, got %T", sel.Columns[0])
212 }
213
214 // Qualified identifier should have position of the table qualifier
215 assertPos(t, "Identifier(u.id).Pos", ident.Pos)
216 if ident.Name != "id" || ident.Table != "u" {
217 t.Errorf("expected u.id, got %s.%s", ident.Table, ident.Name)
218 }
219}
220
221// -----------------------------------------------------------------------------
222// TestFunctionCallPosition verifies FunctionCall nodes carry positions

Callers

nothing calls this directly

Calls 4

parseWithPositionsFunction · 0.85
assertPosFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected