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

Function TestFallbackUtilityCommands

tests/integration/fallback_test.go:278–417  ·  view source on GitHub ↗

TestFallbackUtilityCommands tests DuckDB utility commands that don't support EXPLAIN

(t *testing.T)

Source from the content-addressed store, hash-verified

276
277// TestFallbackUtilityCommands tests DuckDB utility commands that don't support EXPLAIN
278func TestFallbackUtilityCommands(t *testing.T) {
279 if testHarness == nil || testHarness.DuckgresDB == nil {
280 t.Skip("Test harness not available")
281 }
282
283 db := testHarness.DuckgresDB
284
285 t.Run("attach_detach", func(t *testing.T) {
286 skipIfKnown(t)
287
288 // ATTACH a memory database
289 _, err := db.Exec("ATTACH ':memory:' AS util_test_db")
290 if err != nil {
291 t.Fatalf("ATTACH failed: %v", err)
292 }
293
294 // Create a table in the attached database
295 _, err = db.Exec("CREATE TABLE util_test_db.test_tbl (id INT)")
296 if err != nil {
297 t.Fatalf("CREATE TABLE in attached db failed: %v", err)
298 }
299
300 // Query the table
301 var count int
302 err = db.QueryRow("SELECT count(*) FROM util_test_db.test_tbl").Scan(&count)
303 if err != nil {
304 t.Fatalf("Query attached db failed: %v", err)
305 }
306
307 // DETACH the database
308 _, err = db.Exec("DETACH util_test_db")
309 if err != nil {
310 t.Fatalf("DETACH failed: %v", err)
311 }
312 })
313
314 // Note: CREATE/DROP SECRET tests are skipped in integration tests
315 // because DuckLake mode creates its own S3 secret which can cause conflicts.
316 // These commands work correctly - verified manually with:
317 // CREATE SECRET test (TYPE S3, KEY_ID 'x', SECRET 'y', REGION 'us-east-1')
318 // DROP SECRET test
319
320 t.Run("use_database", func(t *testing.T) {
321 skipIfKnown(t)
322
323 // Get current database
324 var currentDb string
325 err := db.QueryRow("SELECT current_database()").Scan(&currentDb)
326 if err != nil {
327 t.Fatalf("Get current database failed: %v", err)
328 }
329
330 // Switch to memory database (always available)
331 _, err = db.Exec("USE memory")
332 if err != nil {
333 t.Fatalf("USE memory failed: %v", err)
334 }
335

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected