diff --git a/go.mod b/go.mod index be6ab24..b296786 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,6 @@ require ( google.golang.org/protobuf v1.33.0 gorm.io/driver/mysql v1.5.6 gorm.io/driver/postgres v1.5.7 - gorm.io/driver/sqlite v1.5.5 gorm.io/gorm v1.25.10 gorm.io/plugin/dbresolver v1.5.1 k8s.io/api v0.30.0 @@ -132,7 +131,7 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-gonic/gin v1.9.1 github.com/glebarez/go-sqlite v1.22.0 // indirect - github.com/glebarez/sqlite v1.11.0 // indirect + github.com/glebarez/sqlite v1.11.0 github.com/go-playground/locales v0.14.1 github.com/go-playground/universal-translator v0.18.1 github.com/go-playground/validator/v10 v10.19.0 @@ -152,7 +151,6 @@ require ( github.com/klauspost/compress v1.17.8 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/microsoft/go-mssqldb v1.7.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/go.sum b/go.sum index bbbc55b..2b73f5f 100644 --- a/go.sum +++ b/go.sum @@ -359,8 +359,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU= github.com/microsoft/go-mssqldb v1.7.1 h1:KU/g8aWeM3Hx7IMOFpiwYiUkU+9zeISb4+tx3ScVfsM= @@ -680,8 +678,6 @@ gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8= gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM= gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA= -gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= -gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= gorm.io/driver/sqlserver v1.5.3 h1:rjupPS4PVw+rjJkfvr8jn2lJ8BMhT4UW5FwuJY0P3Z0= gorm.io/driver/sqlserver v1.5.3/go.mod h1:B+CZ0/7oFJ6tAlefsKoyxdgDCXJKSgwS2bMOQZT0I00= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= diff --git a/pkg/config/gormdb/open.go b/pkg/config/gormdb/open.go index b6d7ceb..8ee0877 100644 --- a/pkg/config/gormdb/open.go +++ b/pkg/config/gormdb/open.go @@ -1,8 +1,7 @@ -//go:build !sqlite3 - package gormdb import ( + "github.com/glebarez/sqlite" dm "github.com/nfjBill/gorm-driver-dm" "gorm.io/driver/mysql" "gorm.io/driver/postgres" @@ -13,4 +12,5 @@ var Opens = map[string]func(string) gorm.Dialector{ "mysql": mysql.Open, "postgres": postgres.Open, "dm": dm.Open, + "sqlite": sqlite.Open, } diff --git a/pkg/config/gormdb/open_sqlite3.go b/pkg/config/gormdb/open_sqlite3.go deleted file mode 100644 index 3bbb41a..0000000 --- a/pkg/config/gormdb/open_sqlite3.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build sqlite3 -// +build sqlite3 - -package gormdb - -import ( - dm "github.com/nfjBill/gorm-driver-dm" - "gorm.io/driver/mysql" - "gorm.io/driver/postgres" - "gorm.io/driver/sqlite" - "gorm.io/gorm" -) - -var Opens = map[string]func(string) gorm.Dialector{ - "mysql": mysql.Open, - "postgres": postgres.Open, - "sqlite3": sqlite.Open, - "dm": dm.Open, -} diff --git a/virtual/model/model.go b/virtual/model/model.go index 87e4dc0..4936b65 100644 --- a/virtual/model/model.go +++ b/virtual/model/model.go @@ -134,7 +134,7 @@ func (m *Model) TenantScope(ctx *gin.Context, _ = db.AddError(err) return db } - return db.Where(fmt.Sprintf("`%s`.`tenant_id` = ?", m.TableName()), tenantID) + return db.Where(fmt.Sprintf("%s.tenant_id = ?", m.TableName()), tenantID) } }