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

Function TestANDExpressionPosition

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

Source from the content-addressed store, hash-verified

275}
276
277func TestANDExpressionPosition(t *testing.T) {
278 tree := parseWithPositions(t, "SELECT * FROM users WHERE id = 1 AND active = true")
279
280 sel := tree.Statements[0].(*ast.SelectStatement)
281 if sel.Where == nil {
282 t.Fatal("expected WHERE clause")
283 }
284
285 // The outermost expression should be AND
286 andExpr, ok := sel.Where.(*ast.BinaryExpression)
287 if !ok {
288 t.Fatalf("expected *ast.BinaryExpression for AND, got %T", sel.Where)
289 }
290
291 if andExpr.Operator != "AND" {
292 t.Errorf("expected AND operator, got %q", andExpr.Operator)
293 }
294
295 assertPos(t, "BinaryExpression(AND).Pos", andExpr.Pos)
296}
297
298// -----------------------------------------------------------------------------
299// TestUnaryExpressionPosition verifies UnaryExpression 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