This requires a bunch of changes since the types on these tables are much closer to the underlying types of the Fieldseeker data we are getting back from the API. I now need to use proper UUID types everywhere, which means I had to modify the bob gen config to consistently use google UUID, my UUID library of choice. I also had to add the organization_id to all the fieldseeker tables since we rely on them existing for some of our compound queries. There were some changes to the API type signatures to get things to build. I may yet regret those.
110 lines
3.7 KiB
Go
110 lines
3.7 KiB
Go
// Code generated by BobGen psql v0.0.4-0.20251216163753-8e325b7c773a+dirty. 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/google/uuid"
|
|
"github.com/stephenafamo/bob"
|
|
"github.com/stephenafamo/bob/dialect/psql"
|
|
"github.com/stephenafamo/bob/dialect/psql/dialect"
|
|
"github.com/stephenafamo/bob/expr"
|
|
"github.com/stephenafamo/bob/orm"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
//go:embed trapdata_by_location_id_recent.bob.sql
|
|
var formattedQueries_trapdata_by_location_id_recent string
|
|
|
|
var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[199:498]
|
|
|
|
type TrapDataByLocationIDRecentQuery = orm.ModQuery[*dialect.SelectQuery, trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer]
|
|
|
|
func TrapDataByLocationIDRecent(OrganizationID int32, LocID []uuid.UUID) *TrapDataByLocationIDRecentQuery {
|
|
var expressionTypArgs trapDataByLocationIDRecent
|
|
|
|
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
|
expressionTypArgs.LocID = expr.ToArgs(LocID...)
|
|
|
|
return &TrapDataByLocationIDRecentQuery{
|
|
Query: orm.Query[trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer]{
|
|
ExecQuery: orm.ExecQuery[trapDataByLocationIDRecent]{
|
|
BaseQuery: bob.BaseQuery[trapDataByLocationIDRecent]{
|
|
Expression: expressionTypArgs,
|
|
Dialect: dialect.Dialect,
|
|
QueryType: bob.QueryTypeSelect,
|
|
},
|
|
},
|
|
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (TrapDataByLocationIDRecentRow, error)) {
|
|
return func(row *scan.Row) (any, error) {
|
|
var t TrapDataByLocationIDRecentRow
|
|
row.ScheduleScanByIndex(0, &t.Enddatetime)
|
|
row.ScheduleScanByIndex(1, &t.Globalid)
|
|
row.ScheduleScanByIndex(2, &t.LocID)
|
|
return &t, nil
|
|
}, func(v any) (TrapDataByLocationIDRecentRow, error) {
|
|
return *(v.(*TrapDataByLocationIDRecentRow)), nil
|
|
}
|
|
},
|
|
},
|
|
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
|
q.AppendSelect(expressionTypArgs.subExpr(7, 36))
|
|
q.SetTable(expressionTypArgs.subExpr(42, 253))
|
|
q.AppendWhere(expressionTypArgs.subExpr(260, 273))
|
|
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(283, 299))
|
|
}),
|
|
}
|
|
}
|
|
|
|
type TrapDataByLocationIDRecentRow = struct {
|
|
Enddatetime time.Time `db:"enddatetime"`
|
|
Globalid uuid.UUID `db:"globalid"`
|
|
LocID uuid.UUID `db:"loc_id"`
|
|
}
|
|
|
|
type trapDataByLocationIDRecentTransformer = bob.SliceTransformer[TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow]
|
|
|
|
type trapDataByLocationIDRecent struct {
|
|
OrganizationID bob.Expression
|
|
LocID bob.Expression
|
|
}
|
|
|
|
func (o trapDataByLocationIDRecent) args() iter.Seq[orm.ArgWithPosition] {
|
|
return func(yield func(arg orm.ArgWithPosition) bool) {
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "organizationID",
|
|
Start: 216,
|
|
Stop: 218,
|
|
Expression: o.OrganizationID,
|
|
}) {
|
|
return
|
|
}
|
|
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "locID",
|
|
Start: 236,
|
|
Stop: 238,
|
|
Expression: o.LocID,
|
|
}) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (o trapDataByLocationIDRecent) raw(from, to int) string {
|
|
return trapDataByLocationIDRecentSQL[from:to]
|
|
}
|
|
|
|
func (o trapDataByLocationIDRecent) subExpr(from, to int) bob.Expression {
|
|
return orm.ArgsToExpression(trapDataByLocationIDRecentSQL, from, to, o.args())
|
|
}
|
|
|
|
func (o trapDataByLocationIDRecent) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.subExpr(0, len(trapDataByLocationIDRecentSQL)).WriteSQL(ctx, w, d, start)
|
|
}
|