From 0f2ce0a685df03114e84e23b15955c883c9295ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Garcia?= Date: Tue, 20 Dec 2022 23:07:39 -0300 Subject: [PATCH] Minor refactor: remove the DB.driver field --- ksql.go | 4 +--- ksql_test.go | 1 - test_adapters.go | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ksql.go b/ksql.go index 3249759..6e2196b 100644 --- a/ksql.go +++ b/ksql.go @@ -30,7 +30,6 @@ func initializeQueryCache() map[string]*sync.Map { // interfacing with the "database/sql" package implementing // the KSQL interface `ksql.Provider`. type DB struct { - driver string dialect Dialect db DBAdapter } @@ -133,7 +132,6 @@ func NewWithAdapter( return DB{ dialect: dialect, - driver: dialectName, db: db, }, nil } @@ -463,7 +461,7 @@ func (c DB) Insert( default: // Unsupported drivers should be detected on the New() function, // So we don't expect the code to ever get into this default case. - err = fmt.Errorf("code error: unsupported driver `%s`", c.driver) + err = fmt.Errorf("code error: unsupported driver `%s`", c.dialect.DriverName()) } return err diff --git a/ksql_test.go b/ksql_test.go index a7c09d9..decaf72 100644 --- a/ksql_test.go +++ b/ksql_test.go @@ -27,7 +27,6 @@ func TestNewAdapterWith(t *testing.T) { tt.AssertNoErr(t, err) tt.AssertEqual(t, db.dialect, supportedDialects[dialectName]) - tt.AssertEqual(t, db.driver, dialectName) } }) diff --git a/test_adapters.go b/test_adapters.go index 1632d0d..38956a6 100644 --- a/test_adapters.go +++ b/test_adapters.go @@ -3577,7 +3577,6 @@ func createTables(driver string, connStr string) error { func newTestDB(db DBAdapter, driver string) DB { return DB{ - driver: driver, dialect: supportedDialects[driver], db: db, }