service/reflect: add more debug logs

This commit is contained in:
c9s 2022-06-01 18:29:54 +08:00
parent dfe29e07e7
commit fb63346732
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -9,6 +9,7 @@ import (
"github.com/fatih/camelcase"
gopluralize "github.com/gertd/go-pluralize"
"github.com/jmoiron/sqlx"
"github.com/sirupsen/logrus"
)
var pluralize = gopluralize.NewClient()
@ -188,11 +189,13 @@ func insertType(db *sqlx.DB, record interface{}) error {
func selectAndScanType(ctx context.Context, db *sqlx.DB, sel squirrel.SelectBuilder, tpe interface{}) (interface{}, error) {
sql, args, err := sel.ToSql()
if err != nil {
return nil, err
}
logrus.Debugf("selectAndScanType: %T <- %s", tpe, sql)
logrus.Debugf("queryArgs: %v", args)
rows, err := db.QueryxContext(ctx, sql, args...)
if err != nil {
return nil, err