go-pg / pg

Golang ORM with focus on PostgreSQL features and performance
https://pg.uptrace.dev/
BSD 2-Clause "Simplified" License
5.67k stars 404 forks source link

Scan JSON value get panic #1979

Open nirsht opened 1 year ago

nirsht commented 1 year ago

https://github.com/go-pg/pg/blob/f7e1c98fed3044ae4e195a0e063f69185fb1885b/types/scan_value.go#LL254C2-L254C2 If the JSON value , this line get panic.

Here is the stack trace

/usr/local/go/src/runtime/panic.go:838 +0x207
reflect.flag.mustBeAssignableSlow(0x0?)
    /usr/local/go/src/reflect/value.go:262 +0x85
reflect.flag.mustBeAssignable(...)
    /usr/local/go/src/reflect/value.go:249
reflect.Value.Set({0x12609e0?, 0xc005366db0?, 0x12609e0?}, {0x12609e0?, 0xc0031bc508?, 0x1f17ca0?})
    /usr/local/go/src/reflect/value.go:2084 +0x6a
github.com/go-pg/pg/v10/types.scanJSONValue({0x12609e0?, 0xc005366db0?, 0xc00b8f23b8?}, {0x1618b08?, 0xc01080a1e0}, 0x791)
    /go/pkg/mod/github.com/go-pg/pg/v10@v10.10.6/types/scan_value.go:254 +0x7a
github.com/go-pg/pg/v10/types.ScanValue({0x12609e0?, 0xc005366db0?, 0x13a0fc0?}, {0x1618b08, 0xc01080a1e0}, 0xc003c08340?)
    /go/pkg/mod/github.com/go-pg/pg/v10@v10.10.6/types/scan_value.go:177 +0x13a
github.com/go-pg/pg/v10/types.scanIfaceValue({0x1241bc0?, 0xc031f801b8?, 0x0?}, {0x1618b08, 0xc01080a1e0}, 0x4?)
    /go/pkg/mod/github.com/go-pg/pg/v10@v10.10.6/types/scan_value.go:167 +0xb2
github.com/go-pg/pg/v10/orm.(*Field).ScanValue(0xc002f5ec80, {0x132e1a0?, 0xc031f80000?, 0x4?}, {0x1618b08, 0xc01080a1e0}, 0x791)
    /go/pkg/mod/github.com/go-pg/pg/v10@v10.10.6/orm/field.go:125 +0xd4
github.com/go-pg/pg/v10/orm.(*structTableModel).scanColumn(0xc003b149c0, {0x3c01?, 0xc0?, {0xc02504c200?, 0xb?}}, {0x1618b08, 0xc01080a1e0}, 0x791)
    /go/pkg/mod/github.com/go-pg/pg/v10@v10.10.6/orm/model_table_struct.go:298 +0x189
elliotcourant commented 1 year ago

If this is still an active problem I can try to take a look at it this weekend