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

Function TestProtocolRowDescription

tests/integration/protocol_test.go:477–524  ·  view source on GitHub ↗

TestProtocolRowDescription tests that column metadata is correctly returned

(t *testing.T)

Source from the content-addressed store, hash-verified

475
476// TestProtocolRowDescription tests that column metadata is correctly returned
477func TestProtocolRowDescription(t *testing.T) {
478 t.Run("column_names", func(t *testing.T) {
479 rows, err := testHarness.DuckgresDB.Query("SELECT 1 AS col_a, 2 AS col_b, 3 AS col_c")
480 if err != nil {
481 t.Fatalf("Query failed: %v", err)
482 }
483 defer func() { _ = rows.Close() }()
484
485 columns, err := rows.Columns()
486 if err != nil {
487 t.Fatalf("Columns failed: %v", err)
488 }
489
490 expected := []string{"col_a", "col_b", "col_c"}
491 if len(columns) != len(expected) {
492 t.Fatalf("Expected %d columns, got %d", len(expected), len(columns))
493 }
494 for i, col := range columns {
495 if col != expected[i] {
496 t.Errorf("Column %d: expected %q, got %q", i, expected[i], col)
497 }
498 }
499 })
500
501 t.Run("column_types", func(t *testing.T) {
502 rows, err := testHarness.DuckgresDB.Query("SELECT 1::INTEGER, 'text'::TEXT, TRUE::BOOLEAN")
503 if err != nil {
504 t.Fatalf("Query failed: %v", err)
505 }
506 defer func() { _ = rows.Close() }()
507
508 types, err := rows.ColumnTypes()
509 if err != nil {
510 t.Fatalf("ColumnTypes failed: %v", err)
511 }
512
513 if len(types) != 3 {
514 t.Fatalf("Expected 3 column types, got %d", len(types))
515 }
516
517 // Just verify we can access type info
518 for i, ct := range types {
519 name := ct.Name()
520 dbType := ct.DatabaseTypeName()
521 t.Logf("Column %d: name=%q, dbType=%q", i, name, dbType)
522 }
523 })
524}
525
526// TestProtocolMultipleStatements tests handling of multiple statements
527func TestProtocolMultipleStatements(t *testing.T) {

Callers

nothing calls this directly

Calls 7

RunMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65
ColumnsMethod · 0.65
ColumnTypesMethod · 0.65
NameMethod · 0.65
DatabaseTypeNameMethod · 0.65

Tested by

no test coverage detected