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

Function TestFallbackMixedSession

tests/integration/fallback_test.go:538–591  ·  view source on GitHub ↗

TestFallbackMixedSession tests that switching between PostgreSQL-valid and DuckDB-specific queries in the same session works correctly

(t *testing.T)

Source from the content-addressed store, hash-verified

536// TestFallbackMixedSession tests that switching between PostgreSQL-valid
537// and DuckDB-specific queries in the same session works correctly
538func TestFallbackMixedSession(t *testing.T) {
539 if testHarness == nil || testHarness.DuckgresDB == nil {
540 t.Skip("Test harness not available")
541 }
542
543 db := testHarness.DuckgresDB
544
545 t.Run("alternate_pg_and_duckdb_syntax", func(t *testing.T) {
546 skipIfKnown(t)
547
548 // 1. Standard PostgreSQL query
549 _, err := db.Exec("SELECT 1")
550 if err != nil {
551 t.Fatalf("Standard SELECT failed: %v", err)
552 }
553
554 // 2. DuckDB-specific DESCRIBE
555 rows, err := db.Query("DESCRIBE SELECT 1 AS num")
556 if err != nil {
557 t.Fatalf("DESCRIBE failed: %v", err)
558 }
559 _ = rows.Close()
560
561 // 3. Another standard PostgreSQL query
562 _, err = db.Exec("SELECT * FROM users LIMIT 1")
563 if err != nil {
564 t.Fatalf("Second standard SELECT failed: %v", err)
565 }
566
567 // 4. DuckDB-specific FROM-first syntax
568 rows, err = db.Query("FROM users SELECT name LIMIT 1")
569 if err != nil {
570 t.Fatalf("FROM-first query failed: %v", err)
571 }
572 _ = rows.Close()
573
574 // 5. PostgreSQL-style type cast
575 var result string
576 err = db.QueryRow("SELECT 'hello'::text").Scan(&result)
577 if err != nil {
578 t.Fatalf("Type cast query failed: %v", err)
579 }
580 if result != "hello" {
581 t.Errorf("Expected 'hello', got %q", result)
582 }
583
584 // 6. Another DuckDB-specific query (SUMMARIZE)
585 rows, err = db.Query("SUMMARIZE SELECT * FROM users LIMIT 1")
586 if err != nil {
587 t.Fatalf("SUMMARIZE failed: %v", err)
588 }
589 _ = rows.Close()
590 })
591}

Callers

nothing calls this directly

Calls 6

skipIfKnownFunction · 0.85
RunMethod · 0.65
ExecMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected