Querying nullable row #1434
hayleyjames
started this conversation in
General
Replies: 1 comment 1 reply
-
// CompositeFields represents the values of a composite value. It can be used as an encoding source or as a scan target.
// It cannot scan a NULL, but the composite fields can be NULL.
type CompositeFields []any You can make a custom type. However, your link is to the pgtype documentation for v4. To make a type that can scan a Or you could use pgx's support for handling var p *MyThing
QueryRow(...).Scan(&p) If a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to select from two tables using a subquery that returns a nullable row.
This is my query:
SELECT id, display_name, (SELECT ROW(id, line_one) FROM address WHERE address.id = address_id) as address FROM account;
I've tried using
pgtype.CompositeFields
on its own and in a custom type, but I get a cannot scan error.Is my use case supported by pgx?
Beta Was this translation helpful? Give feedback.
All reactions