Add db uuid4 func and uuid insert message param

This commit is contained in:
dwrz
2026-10-09 16:52:31 +00:00
parent f365ccad16
commit e8b239649a
3 changed files with 65 additions and 1 deletions
+8
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"regexp"
"sync"
"uuid"
"github.com/mattn/go-sqlite3"
)
@@ -55,6 +56,13 @@ func Connect(ctx context.Context, cfg Config) (*SQLite, error) {
driverOnce.Do(func() {
sql.Register("odidere_sqlite", &sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
if err := conn.RegisterFunc(
"uuid4",
func() string { return uuid.New().String() },
false,
); err != nil {
return fmt.Errorf("failed to register uuid4: %w", err)
}
if err := conn.RegisterFunc(
"regexp",
func(re, s string) (bool, error) {