----------------------------------------------------------------------------- TestIdentifierPosition verifies Identifier nodes carry positions -----------------------------------------------------------------------------
(t *testing.T)
| 178 | // ----------------------------------------------------------------------------- |
| 179 | |
| 180 | func 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 | |
| 200 | func TestQualifiedIdentifierPosition(t *testing.T) { |
| 201 | tree := parseWithPositions(t, "SELECT u.id FROM users u") |
nothing calls this directly
no test coverage detected