Skip to content

Commit 8fec733

Browse files
authored
✨ feat: support pure-Go SQLite driver for GORM (#104)
1 parent 372c322 commit 8fec733

File tree

5 files changed

+4
-29
lines changed

5 files changed

+4
-29
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ require (
3737
google.golang.org/protobuf v1.33.0
3838
gorm.io/driver/mysql v1.5.6
3939
gorm.io/driver/postgres v1.5.7
40-
gorm.io/driver/sqlite v1.5.5
4140
gorm.io/gorm v1.25.10
4241
gorm.io/plugin/dbresolver v1.5.1
4342
k8s.io/api v0.30.0
@@ -132,7 +131,7 @@ require (
132131
github.com/gin-contrib/sse v0.1.0 // indirect
133132
github.com/gin-gonic/gin v1.9.1
134133
github.com/glebarez/go-sqlite v1.22.0 // indirect
135-
github.com/glebarez/sqlite v1.11.0 // indirect
134+
github.com/glebarez/sqlite v1.11.0
136135
github.com/go-playground/locales v0.14.1
137136
github.com/go-playground/universal-translator v0.18.1
138137
github.com/go-playground/validator/v10 v10.19.0
@@ -152,7 +151,6 @@ require (
152151
github.com/klauspost/compress v1.17.8 // indirect
153152
github.com/leodido/go-urn v1.4.0 // indirect
154153
github.com/mattn/go-isatty v0.0.20 // indirect
155-
github.com/mattn/go-sqlite3 v1.14.22 // indirect
156154
github.com/microsoft/go-mssqldb v1.7.1 // indirect
157155
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
158156
github.com/modern-go/reflect2 v1.0.2 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
359359
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
360360
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
361361
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
362-
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
363-
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
364362
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
365363
github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU=
366364
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=
680678
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
681679
gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM=
682680
gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
683-
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
684-
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
685681
gorm.io/driver/sqlserver v1.5.3 h1:rjupPS4PVw+rjJkfvr8jn2lJ8BMhT4UW5FwuJY0P3Z0=
686682
gorm.io/driver/sqlserver v1.5.3/go.mod h1:B+CZ0/7oFJ6tAlefsKoyxdgDCXJKSgwS2bMOQZT0I00=
687683
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=

pkg/config/gormdb/open.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
//go:build !sqlite3
2-
31
package gormdb
42

53
import (
4+
"github.com/glebarez/sqlite"
65
dm "github.com/nfjBill/gorm-driver-dm"
76
"gorm.io/driver/mysql"
87
"gorm.io/driver/postgres"
@@ -13,4 +12,5 @@ var Opens = map[string]func(string) gorm.Dialector{
1312
"mysql": mysql.Open,
1413
"postgres": postgres.Open,
1514
"dm": dm.Open,
15+
"sqlite": sqlite.Open,
1616
}

pkg/config/gormdb/open_sqlite3.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

virtual/model/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (m *Model) TenantScope(ctx *gin.Context,
134134
_ = db.AddError(err)
135135
return db
136136
}
137-
return db.Where(fmt.Sprintf("`%s`.`tenant_id` = ?", m.TableName()), tenantID)
137+
return db.Where(fmt.Sprintf("%s.tenant_id = ?", m.TableName()), tenantID)
138138
}
139139
}
140140

0 commit comments

Comments
 (0)