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)) } } }