From 4a5d2bd6e53cc5265f1d102e1576e0b44ec9407a Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Fri, 15 Nov 2019 05:28:17 +1100 Subject: [PATCH] Register regexp func in init (#202) --- pkg/database/database.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/database/database.go b/pkg/database/database.go index 24b845340..f3597c84e 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -3,7 +3,9 @@ package database import ( "database/sql" "fmt" + "os" "regexp" + "github.com/gobuffalo/packr/v2" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/source" @@ -11,7 +13,6 @@ import ( sqlite3 "github.com/mattn/go-sqlite3" "github.com/stashapp/stash/pkg/logger" "github.com/stashapp/stash/pkg/utils" - "os" ) var DB *sqlx.DB @@ -19,11 +20,13 @@ var appSchemaVersion uint = 1 const sqlite3Driver = "sqlite3_regexp" -func Initialize(databasePath string) { - runMigrations(databasePath) - +func init() { // register custom driver with regexp function registerRegexpFunc() +} + +func Initialize(databasePath string) { + runMigrations(databasePath) // https://github.com/mattn/go-sqlite3 conn, err := sqlx.Open(sqlite3Driver, "file:"+databasePath+"?_fk=true")