Add support for strict scan.
If there are unused columns in query result set Query method panics.
This commit is contained in:
parent
cfc264221b
commit
d86f14e665
9 changed files with 402 additions and 207 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/go-jet/jet/v2/qrm"
|
||||
"github.com/go-jet/jet/v2/stmtcache"
|
||||
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
|
||||
"github.com/jackc/pgx/v4/stdlib"
|
||||
|
|
@ -49,6 +50,8 @@ func skipForCockroachDB(t *testing.T) {
|
|||
func TestMain(m *testing.M) {
|
||||
defer profile.Start().Stop()
|
||||
|
||||
qrm.GlobalConfig.StrictScan = true
|
||||
|
||||
for _, driverName := range []string{"postgres", "pgx"} {
|
||||
|
||||
fmt.Printf("\nRunning postgres tests for driver: %s, caching enabled: %t \n", driverName, withStatementCaching)
|
||||
|
|
@ -95,6 +98,16 @@ func getConnectionString() string {
|
|||
return dbconfig.PostgresConnectString
|
||||
}
|
||||
|
||||
func allowUnusedColumns(f func()) {
|
||||
defer func() {
|
||||
qrm.GlobalConfig.StrictScan = true
|
||||
}()
|
||||
|
||||
qrm.GlobalConfig.StrictScan = false
|
||||
|
||||
f()
|
||||
}
|
||||
|
||||
var loggedSQL string
|
||||
var loggedSQLArgs []interface{}
|
||||
var loggedDebugSQL string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue