MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestSessionSetSearchPath

Function TestSessionSetSearchPath

tests/integration/session_test.go:10–35  ·  view source on GitHub ↗

TestSessionSetSearchPath verifies SET search_path is forwarded to DuckDB (not silently ignored) so that unqualified table names resolve correctly.

(t *testing.T)

Source from the content-addressed store, hash-verified

8// TestSessionSetSearchPath verifies SET search_path is forwarded to DuckDB
9// (not silently ignored) so that unqualified table names resolve correctly.
10func TestSessionSetSearchPath(t *testing.T) {
11 db := testHarness.DuckgresDB
12
13 // Save original search_path so we can restore it after the test
14 var originalPath string
15 if err := db.QueryRow("SHOW search_path").Scan(&originalPath); err != nil {
16 t.Fatalf("SHOW search_path (before) failed: %v", err)
17 }
18 t.Cleanup(func() {
19 _, _ = db.Exec("SET search_path TO '" + originalPath + "'")
20 })
21 // SET search_path and then SHOW it — should return the new value, not a hardcoded default
22 _, err := db.Exec("SET search_path TO 'main'")
23 if err != nil {
24 t.Fatalf("SET search_path failed: %v", err)
25 }
26
27 var searchPath string
28 err = db.QueryRow("SHOW search_path").Scan(&searchPath)
29 if err != nil {
30 t.Fatalf("SHOW search_path failed: %v", err)
31 }
32 if !strings.Contains(searchPath, "main") {
33 t.Errorf("expected search_path to contain 'main', got %q", searchPath)
34 }
35}
36
37// TestSessionSetCommands tests SET command handling
38func TestSessionSetCommands(t *testing.T) {

Callers

nothing calls this directly

Calls 2

ScanMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected