feat: add StrictFieldMapping config

This commit is contained in:
k4n4ry 2025-12-29 23:27:27 +09:00
parent adef2f9b1a
commit f33c2ee357
4 changed files with 219 additions and 9 deletions

View file

@ -4,15 +4,17 @@ import (
"context"
"database/sql"
"fmt"
"os"
"runtime"
"testing"
"github.com/go-jet/jet/v2/internal/utils/throw"
"github.com/go-jet/jet/v2/qrm"
"github.com/go-jet/jet/v2/sqlite"
"github.com/go-jet/jet/v2/stmtcache"
"github.com/go-jet/jet/v2/tests/dbconfig"
"github.com/pkg/profile"
"github.com/stretchr/testify/require"
"os"
"runtime"
"testing"
_ "github.com/mattn/go-sqlite3"
)
@ -57,6 +59,20 @@ func TestMain(m *testing.M) {
}
func allowUnmappedFields(f func()) {
previous := qrm.GlobalConfig.StrictFieldMapping
defer func() { qrm.GlobalConfig.StrictFieldMapping = previous }()
qrm.GlobalConfig.StrictFieldMapping = false
f()
}
func requireStrictFieldMapping(f func()) {
previous := qrm.GlobalConfig.StrictFieldMapping
defer func() { qrm.GlobalConfig.StrictFieldMapping = previous }()
qrm.GlobalConfig.StrictFieldMapping = true
f()
}
func runCount(stmtCaching bool) int {
if stmtCaching {
return 4