Hi,
I'd like to scan into a recursive struct:
type Node struct {
ID string
Parent *Node
}
var nodes []*Node
err := sqlscan.Select(ctx, conns.PgClient, &nodes, `select id, null as parent from nodes where parent_id is null`)
This causes an infinite loop as scany introspects struct recursively.
Any tips for achieving that? I might be missing something obvious since I'm new to Go and scany. Ideally I'd like not to touch the Node struct definition since in my real-life code it is auto-generated. Also I'd like to avoid using db:"-" on Parent since I might want to get the immediate parent with a join.
Thanks!
Hi,
I'd like to scan into a recursive struct:
This causes an infinite loop as scany introspects struct recursively.
Any tips for achieving that? I might be missing something obvious since I'm new to Go and scany. Ideally I'd like not to touch the Node struct definition since in my real-life code it is auto-generated. Also I'd like to avoid using
db:"-"on Parent since I might want to get the immediate parent with a join.Thanks!