2025-12-02 00:28:14 +00:00
|
|
|
// Code generated by BobGen psql v0.42.0. DO NOT EDIT.
|
2025-11-05 17:15:33 +00:00
|
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
|
|
|
|
|
|
package sql
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
2025-11-24 18:08:24 +00:00
|
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
2025-11-05 17:15:33 +00:00
|
|
|
"github.com/jaswdr/faker/v2"
|
2025-11-20 20:59:28 +00:00
|
|
|
"github.com/shopspring/decimal"
|
2025-11-05 17:15:33 +00:00
|
|
|
"github.com/stephenafamo/bob"
|
|
|
|
|
pg_query "github.com/wasilibs/go-pgquery"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Set the testDB to enable tests that use the database
|
|
|
|
|
var testDB bob.Transactor[bob.Tx]
|
|
|
|
|
|
|
|
|
|
func formatQuery(s string) (string, error) {
|
|
|
|
|
aTree, err := pg_query.Parse(s)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pg_query.Deparse(aTree)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var defaultFaker = faker.New()
|
|
|
|
|
|
2025-11-20 20:59:28 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-05 17:36:32 +00:00
|
|
|
func random_enums_Arcgislicensetype(f *faker.Faker, limits ...string) enums.Arcgislicensetype {
|
2025-11-05 17:15:33 +00:00
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-05 17:36:32 +00:00
|
|
|
var e enums.Arcgislicensetype
|
2025-11-05 17:15:33 +00:00
|
|
|
all := e.All()
|
|
|
|
|
return all[f.IntBetween(0, len(all)-1)]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func random_enums_Hashtype(f *faker.Faker, limits ...string) enums.Hashtype {
|
|
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var e enums.Hashtype
|
|
|
|
|
all := e.All()
|
|
|
|
|
return all[f.IntBetween(0, len(all)-1)]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func random_int32(f *faker.Faker, limits ...string) int32 {
|
|
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return f.Int32()
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 20:59:28 +00:00
|
|
|
func random_int64(f *faker.Faker, limits ...string) int64 {
|
|
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return f.Int64()
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-05 17:15:33 +00:00
|
|
|
func random_string(f *faker.Faker, limits ...string) string {
|
|
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val := strings.Join(f.Lorem().Words(f.IntBetween(1, 5)), " ")
|
|
|
|
|
if len(limits) == 0 {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
limitInt, _ := strconv.Atoi(limits[0])
|
|
|
|
|
if limitInt > 0 && limitInt < len(val) {
|
|
|
|
|
val = val[:limitInt]
|
|
|
|
|
}
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func random_time_Time(f *faker.Faker, limits ...string) time.Time {
|
|
|
|
|
if f == nil {
|
|
|
|
|
f = &defaultFaker
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
year := time.Hour * 24 * 365
|
|
|
|
|
min := time.Now().Add(-year)
|
|
|
|
|
max := time.Now().Add(year)
|
|
|
|
|
return f.Time().TimeBetween(min, max)
|
|
|
|
|
}
|