This is extremely useful for testing. In order to do this I needed to actually deploy the migration to a bob fork so I could start to add support for behaviors I really want. Specifically the ability to search for ids in a slice.
115 lines
3.8 KiB
Go
115 lines
3.8 KiB
Go
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package sql
|
|
|
|
import (
|
|
"context"
|
|
_ "embed"
|
|
"io"
|
|
"iter"
|
|
"time"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
|
"github.com/Gleipnir-Technology/bob/expr"
|
|
"github.com/Gleipnir-Technology/bob/orm"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/google/uuid"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
//go:embed trapcount_by_location_id.bob.sql
|
|
var formattedQueries_trapcount_by_location_id string
|
|
|
|
var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[159:609]
|
|
|
|
type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]
|
|
|
|
func TrapCountByLocationID(OrganizationID int32, LocID []uuid.UUID) *TrapCountByLocationIDQuery {
|
|
var expressionTypArgs trapCountByLocationID
|
|
|
|
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
|
expressionTypArgs.LocID = expr.ToArgs(LocID...)
|
|
|
|
return &TrapCountByLocationIDQuery{
|
|
Query: orm.Query[trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]{
|
|
ExecQuery: orm.ExecQuery[trapCountByLocationID]{
|
|
BaseQuery: bob.BaseQuery[trapCountByLocationID]{
|
|
Expression: expressionTypArgs,
|
|
Dialect: dialect.Dialect,
|
|
QueryType: bob.QueryTypeSelect,
|
|
},
|
|
},
|
|
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (TrapCountByLocationIDRow, error)) {
|
|
return func(row *scan.Row) (any, error) {
|
|
var t TrapCountByLocationIDRow
|
|
row.ScheduleScanByIndex(0, &t.TrapdataGlobalid)
|
|
row.ScheduleScanByIndex(1, &t.TrapdataEnddate)
|
|
row.ScheduleScanByIndex(2, &t.TotalFemales)
|
|
row.ScheduleScanByIndex(3, &t.TotalMales)
|
|
row.ScheduleScanByIndex(4, &t.Total)
|
|
return &t, nil
|
|
}, func(v any) (TrapCountByLocationIDRow, error) {
|
|
return *(v.(*TrapCountByLocationIDRow)), nil
|
|
}
|
|
},
|
|
},
|
|
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
|
q.AppendSelect(expressionTypArgs.subExpr(12, 223))
|
|
q.SetTable(expressionTypArgs.subExpr(234, 336))
|
|
q.AppendWhere(expressionTypArgs.subExpr(348, 397))
|
|
q.AppendGroup(expressionTypArgs.subExpr(412, 450))
|
|
}),
|
|
}
|
|
}
|
|
|
|
type TrapCountByLocationIDRow = struct {
|
|
TrapdataGlobalid uuid.UUID `db:"trapdata_globalid"`
|
|
TrapdataEnddate null.Val[time.Time] `db:"trapdata_enddate"`
|
|
TotalFemales int64 `db:"total_females"`
|
|
TotalMales int64 `db:"total_males"`
|
|
Total int64 `db:"total"`
|
|
}
|
|
|
|
type trapCountByLocationIDTransformer = bob.SliceTransformer[TrapCountByLocationIDRow, []TrapCountByLocationIDRow]
|
|
|
|
type trapCountByLocationID struct {
|
|
OrganizationID bob.Expression
|
|
LocID bob.Expression
|
|
}
|
|
|
|
func (o trapCountByLocationID) args() iter.Seq[orm.ArgWithPosition] {
|
|
return func(yield func(arg orm.ArgWithPosition) bool) {
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "organizationID",
|
|
Start: 369,
|
|
Stop: 371,
|
|
Expression: o.OrganizationID,
|
|
}) {
|
|
return
|
|
}
|
|
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "locID",
|
|
Start: 394,
|
|
Stop: 396,
|
|
Expression: o.LocID,
|
|
}) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (o trapCountByLocationID) raw(from, to int) string {
|
|
return trapCountByLocationIDSQL[from:to]
|
|
}
|
|
|
|
func (o trapCountByLocationID) subExpr(from, to int) bob.Expression {
|
|
return orm.ArgsToExpression(trapCountByLocationIDSQL, from, to, o.args())
|
|
}
|
|
|
|
func (o trapCountByLocationID) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.subExpr(0, len(trapCountByLocationIDSQL)).WriteSQL(ctx, w, d, start)
|
|
}
|