From 42b16293b40bd66c92295930192e4caafff92777 Mon Sep 17 00:00:00 2001 From: what Date: Sun, 30 Jul 2023 19:12:56 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E4=B8=B0=E5=AF=8C=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- builder_test.go | 10 ++++++++++ scan.go | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 builder_test.go diff --git a/builder_test.go b/builder_test.go new file mode 100644 index 0000000..425c2ab --- /dev/null +++ b/builder_test.go @@ -0,0 +1,10 @@ +package db + +import "testing" + +func TestJoinSub(t *testing.T) { + b := NewBuilder(conn) + b.Grammar = &Sqlite3Grammar{} + + t.Log(b.On("Select 1 as a, 2 as b", "t1", "true").ToSql()) +} diff --git a/scan.go b/scan.go index fa2d1ac..5da2857 100644 --- a/scan.go +++ b/scan.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" "reflect" + + "github.com/samber/lo" ) type RowScan struct { @@ -139,7 +141,7 @@ func sStructSlice(rows *sql.Rows, dest any) (result RowScan) { if data := *scanArgs[i].(*[]uint8); len(data) > 0 { v := rv.Addr().Interface() if err := json.Unmarshal(data, &v); err != nil { - panic(fmt.Sprintf("[%s:%v] => %s", rv.Kind(), data, err)) + panic(fmt.Sprintf("[%s:%s:%s] => %s", lo.Must1(lo.FindKey(keys, i)), rv.Kind(), data, err)) } } } @@ -213,7 +215,7 @@ func sStruct(rows *sql.Rows, dest any) (result RowScan) { if data := *scanArgs[i].(*[]uint8); len(data) > 0 { v := rv.Addr().Interface() if err := json.Unmarshal(data, &v); err != nil { - panic(fmt.Sprintf("[%s:%v] => %s", rv.Kind(), data, err)) + panic(fmt.Sprintf("[%s:%s:%s] => %s", lo.Must1(lo.FindKey(keys, i)), rv.Kind(), data, err)) } } }