From d5c7926e9748a16fb2cbef92e1a3dc8d3a44bc31 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Thu, 12 Jun 2025 17:45:09 -0700 Subject: [PATCH] revert InitModuleDB pattern, back to single ModuleDB func --- dbx.go | 13 ++----------- dbxm/mysql.go | 2 +- dbxp/pxg.go | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/dbx.go b/dbx.go index d4c0da4..026c08a 100644 --- a/dbx.go +++ b/dbx.go @@ -92,17 +92,8 @@ func SQLO() *sql.DB { return sqlDB } -// ModuleDB returns the existing database module, or panics if it has not -// been initialized yet. -func ModuleDB() *app.Module { - if dbxshared.DBModule == nil { - panic("ModuleDB not initialized yet") - } - return dbxshared.DBModule -} - -// InitModuleDB returns the database module with the provided configuration. -func InitModuleDB(dialect Dialect, cfg *DBConfig, forceDebugLog bool) *app.Module { +// ModuleDB returns the database module with the provided configuration. +func ModuleDB(dialect Dialect, cfg *DBConfig, forceDebugLog bool) *app.Module { if dbxshared.DBModule != nil { panic("ModuleDB initialized multiple times") } diff --git a/dbxm/mysql.go b/dbxm/mysql.go index 3344ab5..fcf5ae5 100644 --- a/dbxm/mysql.go +++ b/dbxm/mysql.go @@ -76,7 +76,7 @@ type _mysqlLogger struct{} func (_mysqlLogger) InitLogger() { mysql.SetQueryLogger(func(ctx context.Context, queryInfo mysql.QueryInfo) { _, args := queryInfo.Statement.Sql() - dbx.ModuleDB().Logger().Debug( + dbxshared.DBModule.Logger().Debug( "Executed SQL query", "args", args, "duration", queryInfo.Duration, diff --git a/dbxp/pxg.go b/dbxp/pxg.go index 5efbf6e..d4fc420 100644 --- a/dbxp/pxg.go +++ b/dbxp/pxg.go @@ -76,7 +76,7 @@ type _postgresLogger struct{} func (_postgresLogger) InitLogger() { postgres.SetQueryLogger(func(ctx context.Context, queryInfo postgres.QueryInfo) { _, args := queryInfo.Statement.Sql() - dbx.ModuleDB().Logger().Debug( + dbxshared.DBModule.Logger().Debug( "Executed SQL query", "args", args, "duration", queryInfo.Duration,