Do not check is response is array (fix panic)
This commit is contained in:
1 parent
c3d626f074
commit
13c5ed92f4
3 files changed
+30
-1
No files matched your search
@@ -0,0 +1,18 @@
|
||||
module isp-config-service/migrate
|
||||
|
||||
go 1.22
|
||||
|
||||
require github.com/txix-open/isp-kit v1.31.2
|
||||
|
||||
require (
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.5 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jmoiron/sqlx v1.4.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db.Open(context.Background(), "")
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...a
|
||||
body, _ := httpResp.Body()
|
||||
rows := gjson.GetBytes(body, "results.0.rows")
|
||||
elems := rows.Array()
|
||||
if rows.IsArray() && len(elems) == 0 {
|
||||
if len(elems) == 0 {
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
err = json.Unmarshal([]byte(elems[0].Raw), ptr)
|
||||
|
||||
Reference in new issue
Block a user