snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
31
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/db.go
vendored
Normal file
31
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/db.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...any) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...any) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
36
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/models.go
vendored
Normal file
36
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/models.go
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Author struct {
|
||||
ID int64
|
||||
Name string
|
||||
Bio sql.NullString
|
||||
}
|
||||
|
||||
type WeatherMetric struct {
|
||||
Time time.Time
|
||||
TimezoneShift sql.NullInt32
|
||||
CityName sql.NullString
|
||||
TempC sql.NullFloat64
|
||||
FeelsLikeC sql.NullFloat64
|
||||
TempMinC sql.NullFloat64
|
||||
TempMaxC sql.NullFloat64
|
||||
PressureHpa sql.NullFloat64
|
||||
HumidityPercent sql.NullFloat64
|
||||
WindSpeedMs sql.NullFloat64
|
||||
WindDeg sql.NullInt32
|
||||
Rain1hMm sql.NullFloat64
|
||||
Rain3hMm sql.NullFloat64
|
||||
Snow1hMm sql.NullFloat64
|
||||
Snow3hMm sql.NullFloat64
|
||||
CloudsPercent sql.NullInt32
|
||||
WeatherTypeID sql.NullInt32
|
||||
}
|
||||
105
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/query.sql.go
vendored
Normal file
105
internal/endtoend/testdata/valid_group_by_reference/pganalyzer/go/query.sql.go
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: query.sql
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
const listAuthors = `-- name: ListAuthors :many
|
||||
SELECT id, name as name, bio
|
||||
FROM authors
|
||||
`
|
||||
|
||||
func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listAuthors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Author
|
||||
for rows.Next() {
|
||||
var i Author
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.Bio); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listAuthorsIdenticalAlias = `-- name: ListAuthorsIdenticalAlias :many
|
||||
SELECT id, name as name, bio
|
||||
FROM authors
|
||||
`
|
||||
|
||||
func (q *Queries) ListAuthorsIdenticalAlias(ctx context.Context) ([]Author, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listAuthorsIdenticalAlias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Author
|
||||
for rows.Next() {
|
||||
var i Author
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.Bio); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listMetrics = `-- name: ListMetrics :many
|
||||
SELECT date_trunc('day', time) AS bucket, city_name, AVG(temp_c)
|
||||
FROM weather_metrics
|
||||
WHERE time > NOW() - (6 * INTERVAL '1 month')
|
||||
GROUP BY bucket, city_name
|
||||
ORDER BY bucket DESC
|
||||
`
|
||||
|
||||
type ListMetricsRow struct {
|
||||
Bucket time.Time
|
||||
CityName sql.NullString
|
||||
Avg float64
|
||||
}
|
||||
|
||||
func (q *Queries) ListMetrics(ctx context.Context) ([]ListMetricsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listMetrics)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListMetricsRow
|
||||
for rows.Next() {
|
||||
var i ListMetricsRow
|
||||
if err := rows.Scan(&i.Bucket, &i.CityName, &i.Avg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user