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.
108 lines
3.5 KiB
Go
108 lines
3.5 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"
|
|
|
|
"github.com/aarondl/opt/null"
|
|
"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/orm"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
//go:embed traplocation_by_source_id.bob.sql
|
|
var formattedQueries_traplocation_by_source_id string
|
|
|
|
var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:488]
|
|
|
|
type TrapLocationBySourceIDQuery = orm.ModQuery[*dialect.SelectQuery, trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer]
|
|
|
|
func TrapLocationBySourceID(OrganizationID int32, Globalid uuid.UUID) *TrapLocationBySourceIDQuery {
|
|
var expressionTypArgs trapLocationBySourceID
|
|
|
|
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
|
expressionTypArgs.Globalid = psql.Arg(Globalid)
|
|
|
|
return &TrapLocationBySourceIDQuery{
|
|
Query: orm.Query[trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer]{
|
|
ExecQuery: orm.ExecQuery[trapLocationBySourceID]{
|
|
BaseQuery: bob.BaseQuery[trapLocationBySourceID]{
|
|
Expression: expressionTypArgs,
|
|
Dialect: dialect.Dialect,
|
|
QueryType: bob.QueryTypeSelect,
|
|
},
|
|
},
|
|
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (TrapLocationBySourceIDRow, error)) {
|
|
return func(row *scan.Row) (any, error) {
|
|
var t TrapLocationBySourceIDRow
|
|
row.ScheduleScanByIndex(0, &t.TrapLocationGlobalid)
|
|
row.ScheduleScanByIndex(1, &t.Distance)
|
|
return &t, nil
|
|
}, func(v any) (TrapLocationBySourceIDRow, error) {
|
|
return *(v.(*TrapLocationBySourceIDRow)), nil
|
|
}
|
|
},
|
|
},
|
|
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
|
q.CombinedLimit.SetLimit(psql.Raw("4"))
|
|
q.AppendSelect(expressionTypArgs.subExpr(9, 102))
|
|
q.SetTable(expressionTypArgs.subExpr(110, 178))
|
|
q.AppendWhere(expressionTypArgs.subExpr(187, 232))
|
|
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(244, 285))
|
|
}),
|
|
}
|
|
}
|
|
|
|
type TrapLocationBySourceIDRow = struct {
|
|
TrapLocationGlobalid null.Val[uuid.UUID] `db:"trap_location_globalid"`
|
|
Distance string `db:"distance"`
|
|
}
|
|
|
|
type trapLocationBySourceIDTransformer = bob.SliceTransformer[TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow]
|
|
|
|
type trapLocationBySourceID struct {
|
|
OrganizationID bob.Expression
|
|
Globalid bob.Expression
|
|
}
|
|
|
|
func (o trapLocationBySourceID) args() iter.Seq[orm.ArgWithPosition] {
|
|
return func(yield func(arg orm.ArgWithPosition) bool) {
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "organizationID",
|
|
Start: 208,
|
|
Stop: 210,
|
|
Expression: o.OrganizationID,
|
|
}) {
|
|
return
|
|
}
|
|
|
|
if !yield(orm.ArgWithPosition{
|
|
Name: "globalid",
|
|
Start: 230,
|
|
Stop: 232,
|
|
Expression: o.Globalid,
|
|
}) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (o trapLocationBySourceID) raw(from, to int) string {
|
|
return trapLocationBySourceIDSQL[from:to]
|
|
}
|
|
|
|
func (o trapLocationBySourceID) subExpr(from, to int) bob.Expression {
|
|
return orm.ArgsToExpression(trapLocationBySourceIDSQL, from, to, o.args())
|
|
}
|
|
|
|
func (o trapLocationBySourceID) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.subExpr(0, len(trapLocationBySourceIDSQL)).WriteSQL(ctx, w, d, start)
|
|
}
|