numeric uuids

main
Bel LaPointe 2025-06-04 18:32:53 -06:00
parent e21b316627
commit c463bd16d8
1 changed files with 10 additions and 4 deletions

14
main.go
View File

@ -206,7 +206,7 @@ func CloneForColumn[T any](db *sql.DB, table, column string, from, to T, fixed m
values := []any{}
for _ = range uuidGenColumns {
values = append(values, fmt.Sprintf("'%s'", strings.ToUpper(uuid.New().String())))
values = append(values, fmt.Sprintf("'%s'", guid()))
}
for _, arg := range args {
values = append(values, *(arg.(*any)))
@ -243,7 +243,7 @@ func CloneForColumn[T any](db *sql.DB, table, column string, from, to T, fixed m
func() string {
uuids := make([]string, len(uuidGenColumns))
for i := range uuids {
uuids[i] = fmt.Sprintf("'%s'", strings.ToUpper(uuid.New().String()))
uuids[i] = fmt.Sprintf("'%s'", guid())
}
s := strings.Join(uuids, ", ")
if len(uuids) > 0 {
@ -399,6 +399,12 @@ func Select[T any](db *sql.DB, q string, args ...any) ([]T, error) {
return results, rows.Err()
}
guid() string {
func guid() string {
s := []byte(uuid.New().String())
for i := range s {
if 'A' <= s[i] && s[i] <= 'Z' {
s[i] = '0' + byte(int(s[i])%10)
}
}
return strings.ToUpper(string(s))
}