2019-02-14 13:33:42 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package pgutil
|
|
|
|
|
|
|
|
import (
|
2020-01-13 13:18:48 +00:00
|
|
|
"context"
|
2019-02-14 13:33:42 +00:00
|
|
|
"strconv"
|
|
|
|
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/dbutil/dbschema"
|
2019-02-14 13:33:42 +00:00
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// QueryData loads all data from tables.
|
2020-01-13 13:18:48 +00:00
|
|
|
func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error) {
|
2020-01-17 18:08:13 +00:00
|
|
|
return dbschema.QueryData(ctx, db, schema, func(columnName string) string {
|
2019-02-14 13:33:42 +00:00
|
|
|
quoted := strconv.Quote(columnName)
|
|
|
|
return `quote_nullable(` + quoted + `) as ` + quoted
|
|
|
|
})
|
|
|
|
}
|