Remove old FieldSeeker tables, use v2 generated tables.
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.
This commit is contained in:
parent
58f5afccc9
commit
1395e3d3ac
445 changed files with 54077 additions and 275856 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- OauthTokenByUserId
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- OrgByOauthId
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -9,8 +9,8 @@ import (
|
|||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jaswdr/faker/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stephenafamo/bob"
|
||||
pg_query "github.com/wasilibs/go-pgquery"
|
||||
)
|
||||
|
|
@ -29,37 +29,6 @@ func formatQuery(s string) (string, error) {
|
|||
|
||||
var defaultFaker = faker.New()
|
||||
|
||||
func random_decimal_Decimal(f *faker.Faker, limits ...string) decimal.Decimal {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
var precision int64 = 7
|
||||
var scale int64 = 3
|
||||
|
||||
if len(limits) > 0 {
|
||||
precision, _ = strconv.ParseInt(limits[0], 10, 32)
|
||||
}
|
||||
|
||||
if len(limits) > 1 {
|
||||
scale, _ = strconv.ParseInt(limits[1], 10, 32)
|
||||
}
|
||||
|
||||
baseVal := f.Float32(10, -1, 1)
|
||||
for baseVal == -1 || baseVal == 0 || baseVal == 1 {
|
||||
baseVal = f.Float32(10, -1, 1)
|
||||
}
|
||||
|
||||
precisionDecimal, _ := decimal.NewFromInt(10).PowInt32(int32(precision))
|
||||
val := decimal.
|
||||
NewFromFloat32(baseVal).
|
||||
Mul(precisionDecimal).
|
||||
Shift(int32(-1 * scale)).
|
||||
RoundDown(int32(scale))
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func random_enums_Arcgislicensetype(f *faker.Faker, limits ...string) enums.Arcgislicensetype {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
|
|
@ -122,3 +91,11 @@ func random_time_Time(f *faker.Faker, limits ...string) time.Time {
|
|||
max := time.Now().Add(year)
|
||||
return f.Time().TimeBetween(min, max)
|
||||
}
|
||||
|
||||
func random_uuid_UUID(f *faker.Faker, limits ...string) uuid.UUID {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
return uuid.New()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -8,9 +8,10 @@ import (
|
|||
_ "embed"
|
||||
"io"
|
||||
"iter"
|
||||
"time"
|
||||
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/stephenafamo/bob/dialect/psql"
|
||||
"github.com/stephenafamo/bob/dialect/psql/dialect"
|
||||
|
|
@ -22,11 +23,11 @@ import (
|
|||
//go:embed trapcount_by_location_id.bob.sql
|
||||
var formattedQueries_trapcount_by_location_id string
|
||||
|
||||
var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[194:626]
|
||||
var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[194:644]
|
||||
|
||||
type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]
|
||||
|
||||
func TrapCountByLocationID(OrganizationID int32, LocID []string) *TrapCountByLocationIDQuery {
|
||||
func TrapCountByLocationID(OrganizationID int32, LocID []uuid.UUID) *TrapCountByLocationIDQuery {
|
||||
var expressionTypArgs trapCountByLocationID
|
||||
|
||||
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
||||
|
|
@ -57,19 +58,19 @@ func TrapCountByLocationID(OrganizationID int32, LocID []string) *TrapCountByLoc
|
|||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(12, 223))
|
||||
q.SetTable(expressionTypArgs.subExpr(234, 318))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(330, 379))
|
||||
q.AppendGroup(expressionTypArgs.subExpr(394, 432))
|
||||
q.SetTable(expressionTypArgs.subExpr(234, 336))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(348, 397))
|
||||
q.AppendGroup(expressionTypArgs.subExpr(412, 450))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TrapCountByLocationIDRow = struct {
|
||||
TrapdataGlobalid string `db:"trapdata_globalid"`
|
||||
TrapdataEnddate null.Val[int64] `db:"trapdata_enddate"`
|
||||
TotalFemales decimal.Decimal `db:"total_females"`
|
||||
TotalMales int64 `db:"total_males"`
|
||||
Total decimal.Decimal `db:"total"`
|
||||
TrapdataGlobalid null.Val[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]
|
||||
|
|
@ -83,8 +84,8 @@ func (o trapCountByLocationID) args() iter.Seq[orm.ArgWithPosition] {
|
|||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "organizationID",
|
||||
Start: 351,
|
||||
Stop: 353,
|
||||
Start: 369,
|
||||
Stop: 371,
|
||||
Expression: o.OrganizationID,
|
||||
}) {
|
||||
return
|
||||
|
|
@ -92,8 +93,8 @@ func (o trapCountByLocationID) args() iter.Seq[orm.ArgWithPosition] {
|
|||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "locID",
|
||||
Start: 376,
|
||||
Stop: 378,
|
||||
Start: 394,
|
||||
Stop: 396,
|
||||
Expression: o.LocID,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- TrapCountByLocationID
|
||||
|
|
@ -9,9 +9,9 @@ SELECT
|
|||
COALESCE(SUM(sa.males), 0) AS total_males,
|
||||
COALESCE(SUM(sa.total), 0) AS total
|
||||
FROM
|
||||
fs_trapdata td
|
||||
fieldseeker.trapdata td
|
||||
LEFT JOIN
|
||||
fs_speciesabundance sa ON td.globalid = sa.trapdata_id
|
||||
fieldseeker.speciesabundance sa ON td.globalid = sa.trapdata_id
|
||||
WHERE
|
||||
td.organization_id = $1
|
||||
AND td.loc_id IN ($2)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -19,7 +19,7 @@ func TestTrapCountByLocationID(t *testing.T) {
|
|||
t.Run("Base", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapCountByLocationID(random_int32(nil), []string{random_string(nil)})
|
||||
query := TrapCountByLocationID(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})
|
||||
|
||||
if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -33,7 +33,7 @@ func TestTrapCountByLocationID(t *testing.T) {
|
|||
t.Run("Mod", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapCountByLocationID(random_int32(nil), []string{random_string(nil)})
|
||||
query := TrapCountByLocationID(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})
|
||||
|
||||
if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -68,7 +68,7 @@ func TestTrapCountByLocationID(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapCountByLocationID(random_int32(nil), []string{random_string(nil)})))
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapCountByLocationID(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ SELECT
|
|||
COALESCE(SUM(sa.males), 0) AS total_males,
|
||||
COALESCE(SUM(sa.total), 0) AS total
|
||||
FROM
|
||||
fs_trapdata td
|
||||
fieldseeker.trapdata td
|
||||
LEFT JOIN
|
||||
fs_speciesabundance sa ON td.globalid = sa.trapdata_id
|
||||
fieldseeker.speciesabundance sa ON td.globalid = sa.trapdata_id
|
||||
WHERE
|
||||
td.organization_id = $1
|
||||
AND td.loc_id IN ($2)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -8,7 +8,9 @@ import (
|
|||
_ "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"
|
||||
|
|
@ -20,11 +22,11 @@ import (
|
|||
//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:489]
|
||||
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 []string) *TrapDataByLocationIDRecentQuery {
|
||||
func TrapDataByLocationIDRecent(OrganizationID int32, LocID []uuid.UUID) *TrapDataByLocationIDRecentQuery {
|
||||
var expressionTypArgs trapDataByLocationIDRecent
|
||||
|
||||
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
||||
|
|
@ -53,17 +55,17 @@ func TrapDataByLocationIDRecent(OrganizationID int32, LocID []string) *TrapDataB
|
|||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(7, 36))
|
||||
q.SetTable(expressionTypArgs.subExpr(42, 244))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(251, 264))
|
||||
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(274, 290))
|
||||
q.SetTable(expressionTypArgs.subExpr(42, 253))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(260, 273))
|
||||
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(283, 299))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TrapDataByLocationIDRecentRow = struct {
|
||||
Enddatetime int64 `db:"enddatetime"`
|
||||
Globalid string `db:"globalid"`
|
||||
LocID string `db:"loc_id"`
|
||||
Enddatetime time.Time `db:"enddatetime"`
|
||||
Globalid uuid.UUID `db:"globalid"`
|
||||
LocID uuid.UUID `db:"loc_id"`
|
||||
}
|
||||
|
||||
type trapDataByLocationIDRecentTransformer = bob.SliceTransformer[TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow]
|
||||
|
|
@ -77,8 +79,8 @@ func (o trapDataByLocationIDRecent) args() iter.Seq[orm.ArgWithPosition] {
|
|||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "organizationID",
|
||||
Start: 207,
|
||||
Stop: 209,
|
||||
Start: 216,
|
||||
Stop: 218,
|
||||
Expression: o.OrganizationID,
|
||||
}) {
|
||||
return
|
||||
|
|
@ -86,8 +88,8 @@ func (o trapDataByLocationIDRecent) args() iter.Seq[orm.ArgWithPosition] {
|
|||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "locID",
|
||||
Start: 227,
|
||||
Stop: 229,
|
||||
Start: 236,
|
||||
Stop: 238,
|
||||
Expression: o.LocID,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- TrapDataByLocationIDRecent
|
||||
|
|
@ -6,7 +6,7 @@ SELECT enddatetime, globalid, loc_id
|
|||
FROM (
|
||||
SELECT enddatetime, globalid, loc_id, ROW_NUMBER()
|
||||
OVER (PARTITION BY loc_id ORDER BY enddatetime DESC) as row_num
|
||||
FROM fs_trapdata
|
||||
FROM fieldseeker.trapdata
|
||||
WHERE
|
||||
organization_id = $1 AND
|
||||
loc_id IN ($2)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -19,7 +19,7 @@ func TestTrapDataByLocationIDRecent(t *testing.T) {
|
|||
t.Run("Base", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapDataByLocationIDRecent(random_int32(nil), []string{random_string(nil)})
|
||||
query := TrapDataByLocationIDRecent(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})
|
||||
|
||||
if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -33,7 +33,7 @@ func TestTrapDataByLocationIDRecent(t *testing.T) {
|
|||
t.Run("Mod", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapDataByLocationIDRecent(random_int32(nil), []string{random_string(nil)})
|
||||
query := TrapDataByLocationIDRecent(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})
|
||||
|
||||
if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -68,7 +68,7 @@ func TestTrapDataByLocationIDRecent(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapDataByLocationIDRecent(random_int32(nil), []string{random_string(nil)})))
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapDataByLocationIDRecent(random_int32(nil), []uuid.UUID{random_uuid_UUID(nil)})))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ SELECT enddatetime, globalid, loc_id
|
|||
FROM (
|
||||
SELECT enddatetime, globalid, loc_id, ROW_NUMBER()
|
||||
OVER (PARTITION BY loc_id ORDER BY enddatetime DESC) as row_num
|
||||
FROM fs_trapdata
|
||||
FROM fieldseeker.trapdata
|
||||
WHERE
|
||||
organization_id = $1 AND
|
||||
loc_id IN ($2)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -9,6 +9,8 @@ import (
|
|||
"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"
|
||||
|
|
@ -19,11 +21,11 @@ import (
|
|||
//go:embed traplocation_by_source_id.bob.sql
|
||||
var formattedQueries_traplocation_by_source_id string
|
||||
|
||||
var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:446]
|
||||
var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:488]
|
||||
|
||||
type TrapLocationBySourceIDQuery = orm.ModQuery[*dialect.SelectQuery, trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer]
|
||||
|
||||
func TrapLocationBySourceID(OrganizationID int32, Globalid string) *TrapLocationBySourceIDQuery {
|
||||
func TrapLocationBySourceID(OrganizationID int32, Globalid uuid.UUID) *TrapLocationBySourceIDQuery {
|
||||
var expressionTypArgs trapLocationBySourceID
|
||||
|
||||
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
||||
|
|
@ -51,17 +53,17 @@ func TrapLocationBySourceID(OrganizationID int32, Globalid string) *TrapLocation
|
|||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.CombinedLimit.SetLimit(psql.Raw("4"))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(9, 90))
|
||||
q.SetTable(expressionTypArgs.subExpr(98, 148))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(157, 202))
|
||||
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(214, 243))
|
||||
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 string `db:"trap_location_globalid"`
|
||||
Distance string `db:"distance"`
|
||||
TrapLocationGlobalid null.Val[uuid.UUID] `db:"trap_location_globalid"`
|
||||
Distance string `db:"distance"`
|
||||
}
|
||||
|
||||
type trapLocationBySourceIDTransformer = bob.SliceTransformer[TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow]
|
||||
|
|
@ -75,8 +77,8 @@ func (o trapLocationBySourceID) args() iter.Seq[orm.ArgWithPosition] {
|
|||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "organizationID",
|
||||
Start: 178,
|
||||
Stop: 180,
|
||||
Start: 208,
|
||||
Stop: 210,
|
||||
Expression: o.OrganizationID,
|
||||
}) {
|
||||
return
|
||||
|
|
@ -84,8 +86,8 @@ func (o trapLocationBySourceID) args() iter.Seq[orm.ArgWithPosition] {
|
|||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "globalid",
|
||||
Start: 200,
|
||||
Stop: 202,
|
||||
Start: 230,
|
||||
Stop: 232,
|
||||
Expression: o.Globalid,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- TrapLocationBySourceID
|
||||
SELECT
|
||||
tl.globalid AS trap_location_globalid,
|
||||
ST_Distance(pl.geom, tl.geom) AS distance
|
||||
ST_Distance(pl.geospatial, tl.geospatial) AS distance
|
||||
FROM
|
||||
fs_pointlocation pl
|
||||
fieldseeker.pointlocation pl
|
||||
CROSS JOIN
|
||||
fs_traplocation tl
|
||||
fieldseeker.traplocation tl
|
||||
WHERE
|
||||
tl.organization_id = $1 AND
|
||||
pl.globalid = $2
|
||||
ORDER BY
|
||||
ST_Distance(pl.geom, tl.geom)
|
||||
ST_Distance(pl.geospatial, tl.geospatial)
|
||||
LIMIT 4;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
@ -19,7 +19,7 @@ func TestTrapLocationBySourceID(t *testing.T) {
|
|||
t.Run("Base", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapLocationBySourceID(random_int32(nil), random_string(nil))
|
||||
query := TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil))
|
||||
|
||||
if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -33,7 +33,7 @@ func TestTrapLocationBySourceID(t *testing.T) {
|
|||
t.Run("Mod", func(t *testing.T) {
|
||||
var sb strings.Builder
|
||||
|
||||
query := TrapLocationBySourceID(random_int32(nil), random_string(nil))
|
||||
query := TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil))
|
||||
|
||||
if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -68,7 +68,7 @@ func TestTrapLocationBySourceID(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapLocationBySourceID(random_int32(nil), random_string(nil))))
|
||||
query, args, err := bob.Build(ctxTx, psql.Select(TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil))))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
-- TrapLocationBySourceID
|
||||
SELECT
|
||||
tl.globalid AS trap_location_globalid,
|
||||
ST_Distance(pl.geom, tl.geom) AS distance
|
||||
ST_Distance(pl.geospatial, tl.geospatial) AS distance
|
||||
FROM
|
||||
fs_pointlocation pl
|
||||
fieldseeker.pointlocation pl
|
||||
CROSS JOIN
|
||||
fs_traplocation tl
|
||||
fieldseeker.traplocation tl
|
||||
WHERE
|
||||
tl.organization_id = $1 AND
|
||||
pl.globalid = $2
|
||||
ORDER BY
|
||||
ST_Distance(pl.geom, tl.geom)
|
||||
ST_Distance(pl.geospatial, tl.geospatial)
|
||||
LIMIT 4
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- UpdateOauthTokenOrg
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
-- 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.
|
||||
|
||||
-- UserByUsername
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
|
||||
// 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue