Add db uuid4 func and uuid insert message param
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user