[feat] 丰富错误提示信息
This commit is contained in:
parent
e24dea4e1e
commit
42b16293b4
10
builder_test.go
Normal file
10
builder_test.go
Normal file
@ -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())
|
||||||
|
}
|
6
scan.go
6
scan.go
@ -6,6 +6,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RowScan struct {
|
type RowScan struct {
|
||||||
@ -139,7 +141,7 @@ func sStructSlice(rows *sql.Rows, dest any) (result RowScan) {
|
|||||||
if data := *scanArgs[i].(*[]uint8); len(data) > 0 {
|
if data := *scanArgs[i].(*[]uint8); len(data) > 0 {
|
||||||
v := rv.Addr().Interface()
|
v := rv.Addr().Interface()
|
||||||
if err := json.Unmarshal(data, &v); err != nil {
|
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 {
|
if data := *scanArgs[i].(*[]uint8); len(data) > 0 {
|
||||||
v := rv.Addr().Interface()
|
v := rv.Addr().Interface()
|
||||||
if err := json.Unmarshal(data, &v); err != nil {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user