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/coalesce/postgresql/stdlib/go/db.go
vendored
Normal file
31
internal/endtoend/testdata/coalesce/postgresql/stdlib/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,
|
||||
}
|
||||
}
|
||||
16
internal/endtoend/testdata/coalesce/postgresql/stdlib/go/models.go
vendored
Normal file
16
internal/endtoend/testdata/coalesce/postgresql/stdlib/go/models.go
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
Bar sql.NullString
|
||||
Bat string
|
||||
Baz sql.NullInt64
|
||||
Qux int64
|
||||
}
|
||||
201
internal/endtoend/testdata/coalesce/postgresql/stdlib/go/query.sql.go
vendored
Normal file
201
internal/endtoend/testdata/coalesce/postgresql/stdlib/go/query.sql.go
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: query.sql
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const coalesceNumeric = `-- name: CoalesceNumeric :many
|
||||
SELECT coalesce(baz, 0) as login
|
||||
FROM foo
|
||||
`
|
||||
|
||||
func (q *Queries) CoalesceNumeric(ctx context.Context) ([]int64, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceNumeric)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []int64
|
||||
for rows.Next() {
|
||||
var login int64
|
||||
if err := rows.Scan(&login); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, login)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const coalesceNumericColumns = `-- name: CoalesceNumericColumns :many
|
||||
SELECT baz, qux, coalesce(baz, qux)
|
||||
FROM foo
|
||||
`
|
||||
|
||||
type CoalesceNumericColumnsRow struct {
|
||||
Baz sql.NullInt64
|
||||
Qux int64
|
||||
Baz_2 int64
|
||||
}
|
||||
|
||||
func (q *Queries) CoalesceNumericColumns(ctx context.Context) ([]CoalesceNumericColumnsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceNumericColumns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CoalesceNumericColumnsRow
|
||||
for rows.Next() {
|
||||
var i CoalesceNumericColumnsRow
|
||||
if err := rows.Scan(&i.Baz, &i.Qux, &i.Baz_2); 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 coalesceNumericNull = `-- name: CoalesceNumericNull :many
|
||||
SELECT baz, coalesce(baz)
|
||||
FROM foo
|
||||
`
|
||||
|
||||
type CoalesceNumericNullRow struct {
|
||||
Baz sql.NullInt64
|
||||
Baz_2 sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) CoalesceNumericNull(ctx context.Context) ([]CoalesceNumericNullRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceNumericNull)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CoalesceNumericNullRow
|
||||
for rows.Next() {
|
||||
var i CoalesceNumericNullRow
|
||||
if err := rows.Scan(&i.Baz, &i.Baz_2); 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 coalesceString = `-- name: CoalesceString :many
|
||||
SELECT coalesce(bar, '') as login
|
||||
FROM foo
|
||||
`
|
||||
|
||||
func (q *Queries) CoalesceString(ctx context.Context) ([]string, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []string
|
||||
for rows.Next() {
|
||||
var login string
|
||||
if err := rows.Scan(&login); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, login)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const coalesceStringColumns = `-- name: CoalesceStringColumns :many
|
||||
SELECT bar, bat, coalesce(bar, bat)
|
||||
FROM foo
|
||||
`
|
||||
|
||||
type CoalesceStringColumnsRow struct {
|
||||
Bar sql.NullString
|
||||
Bat string
|
||||
Bar_2 string
|
||||
}
|
||||
|
||||
func (q *Queries) CoalesceStringColumns(ctx context.Context) ([]CoalesceStringColumnsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceStringColumns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CoalesceStringColumnsRow
|
||||
for rows.Next() {
|
||||
var i CoalesceStringColumnsRow
|
||||
if err := rows.Scan(&i.Bar, &i.Bat, &i.Bar_2); 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 coalesceStringNull = `-- name: CoalesceStringNull :many
|
||||
SELECT bar, coalesce(bar)
|
||||
FROM foo
|
||||
`
|
||||
|
||||
type CoalesceStringNullRow struct {
|
||||
Bar sql.NullString
|
||||
Bar_2 sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) CoalesceStringNull(ctx context.Context) ([]CoalesceStringNullRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, coalesceStringNull)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CoalesceStringNullRow
|
||||
for rows.Next() {
|
||||
var i CoalesceStringNullRow
|
||||
if err := rows.Scan(&i.Bar, &i.Bar_2); 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