.coalesce( fn .jsonAgg( jsonBuildObject({ id: ref("i.id"), label: ref("i.label") }) ) .filterWhere("i.id", "is not", null), sql`[]` ) .as("interests")
{ id: string | null; label: string | null }[]
{ id: string; label: string }[]