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

Function TestAcceptILIKEDefaultDialect

pkg/sql/parser/dialect_test.go:354–373  ·  view source on GitHub ↗

TestAcceptILIKEDefaultDialect checks that ILIKE works when no dialect is set (default is treated as PostgreSQL for backward compatibility).

(t *testing.T)

Source from the content-addressed store, hash-verified

352// TestAcceptILIKEDefaultDialect checks that ILIKE works when no dialect is set
353// (default is treated as PostgreSQL for backward compatibility).
354func TestAcceptILIKEDefaultDialect(t *testing.T) {
355 sql := "SELECT * FROM users WHERE name ILIKE '%alice%'"
356 // When no dialect is set (p.dialect == ""), the gate should not fire.
357 p := NewParser() // dialect == ""
358 tkz, err := tokenizer.NewWithDialect(keywords.DialectPostgreSQL)
359 if err != nil {
360 t.Fatal(err)
361 }
362 tokens, err := tkz.Tokenize([]byte(sql))
363 if err != nil {
364 t.Fatal(err)
365 }
366 result, err := p.ParseFromModelTokens(tokens)
367 if err != nil {
368 t.Fatalf("ILIKE should be valid with default (empty) dialect, got error: %v", err)
369 }
370 if result == nil {
371 t.Fatal("expected non-nil AST")
372 }
373}
374
375// ---------------------------------------------------------------------------
376// Backtick and bracket reserved-word regression tests (DIALECT-1, DIALECT-2)

Callers

nothing calls this directly

Calls 5

ParseFromModelTokensMethod · 0.95
NewWithDialectFunction · 0.92
TokenizeMethod · 0.80
NewParserFunction · 0.70
FatalfMethod · 0.65

Tested by

no test coverage detected