2022-11-18 21:25:40 +01:00
|
|
|
package db
|
|
|
|
|
2022-11-19 15:13:47 +01:00
|
|
|
import (
|
|
|
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
2022-12-07 23:32:58 +01:00
|
|
|
"strings"
|
2022-11-19 15:13:47 +01:00
|
|
|
"time"
|
|
|
|
)
|
2022-11-18 21:25:40 +01:00
|
|
|
|
|
|
|
func bool2DB(b bool) int {
|
|
|
|
if b {
|
|
|
|
return 1
|
|
|
|
} else {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func time2DB(t time.Time) int64 {
|
|
|
|
return t.UnixMilli()
|
|
|
|
}
|
2022-11-19 15:13:47 +01:00
|
|
|
|
|
|
|
func time2DBOpt(t *time.Time) *int64 {
|
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return langext.Ptr(t.UnixMilli())
|
|
|
|
}
|
2022-12-07 23:32:58 +01:00
|
|
|
|
|
|
|
func fmtSQLPrint(sql string) string {
|
|
|
|
if strings.Contains(sql, ";") {
|
|
|
|
return "(...multi...)"
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = strings.ReplaceAll(sql, "\r", "")
|
|
|
|
sql = strings.ReplaceAll(sql, "\n", " ")
|
|
|
|
|
|
|
|
return sql
|
|
|
|
}
|