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

Function TestRejectTopInPostgreSQL

pkg/sql/parser/dialect_test.go:250–259  ·  view source on GitHub ↗

TestRejectTopInPostgreSQL checks that TOP is rejected when dialect is PostgreSQL.

(t *testing.T)

Source from the content-addressed store, hash-verified

248
249// TestRejectTopInPostgreSQL checks that TOP is rejected when dialect is PostgreSQL.
250func TestRejectTopInPostgreSQL(t *testing.T) {
251 sql := "SELECT TOP 10 id, name FROM users"
252 _, err := ParseWithDialect(sql, keywords.DialectPostgreSQL)
253 if err == nil {
254 t.Fatal("expected error: TOP should be rejected in PostgreSQL dialect")
255 }
256 if !containsAny(err.Error(), "TOP", "postgresql", "LIMIT") {
257 t.Errorf("error should mention TOP or PostgreSQL, got: %v", err)
258 }
259}
260
261// TestAcceptTopInSQLServer checks that TOP is accepted in SQL Server dialect.
262func TestAcceptTopInSQLServer(t *testing.T) {

Callers

nothing calls this directly

Calls 4

containsAnyFunction · 0.85
ParseWithDialectFunction · 0.70
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected