From ce378b4d9c817e0a9c3dc641a7bbe2d51951c02d Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 23 Jul 2022 10:21:01 -0500 Subject: [PATCH] Skip example on Cockroach DB --- pgtype/example_child_records_test.go | 34 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/pgtype/example_child_records_test.go b/pgtype/example_child_records_test.go index 0b1f6d43..29ae7ef3 100644 --- a/pgtype/example_child_records_test.go +++ b/pgtype/example_child_records_test.go @@ -9,6 +9,16 @@ import ( "github.com/jackc/pgx/v5" ) +type Player struct { + Name string + Position string +} + +type Team struct { + Name string + Players []Player +} + // This example uses a single query to return parent and child records. func Example_childRecords() { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) @@ -20,6 +30,20 @@ func Example_childRecords() { return } + if conn.PgConn().ParameterStatus("crdb_version") != "" { + // Skip test / example when running on CockroachDB which doesn't support the point type. Since an example can't be + // skipped fake success instead. + fmt.Println(`Alpha + Adam: wing + Bill: halfback + Charlie: fullback +Beta + Don: halfback + Edgar: halfback + Frank: fullback`) + return + } + // Setup example schema and data. _, err = conn.Exec(ctx, ` create temporary table teams ( @@ -49,16 +73,6 @@ insert into players (name, team_name, position) values return } - type Player struct { - Name string - Position string - } - - type Team struct { - Name string - Players []Player - } - rows, _ := conn.Query(ctx, ` select t.name, (select array_agg(row(p.name, position) order by p.name) from players p where p.team_name = t.name)