Skip example on Cockroach DB

pull/1281/head
Jack Christensen 2022-07-23 10:21:01 -05:00
parent 5cee04a026
commit ce378b4d9c
1 changed files with 24 additions and 10 deletions

View File

@ -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)