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

Function TestIdentifierPosition

pkg/sql/ast/positions_test.go:180–198  ·  view source on GitHub ↗

----------------------------------------------------------------------------- TestIdentifierPosition verifies Identifier nodes carry positions -----------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

178// -----------------------------------------------------------------------------
179
180func TestIdentifierPosition(t *testing.T) {
181 tree := parseWithPositions(t, "SELECT id FROM users")
182
183 sel := tree.Statements[0].(*ast.SelectStatement)
184
185 // The first column in SELECT should be an Identifier
186 if len(sel.Columns) == 0 {
187 t.Fatal("expected at least 1 column")
188 }
189
190 ident, ok := sel.Columns[0].(*ast.Identifier)
191 if !ok {
192 t.Fatalf("expected *ast.Identifier, got %T", sel.Columns[0])
193 }
194
195 assertPos(t, "Identifier(id).Pos", ident.Pos)
196 // "id" starts at column 8 in "SELECT id FROM users" (SELECT is 6 chars + space = 7)
197 assertPosEqual(t, "Identifier(id).Pos", ident.Pos, 1, 8)
198}
199
200func TestQualifiedIdentifierPosition(t *testing.T) {
201 tree := parseWithPositions(t, "SELECT u.id FROM users u")

Callers

nothing calls this directly

Calls 4

parseWithPositionsFunction · 0.85
assertPosFunction · 0.85
assertPosEqualFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected