Skip to content

Commit

Permalink
Cannot accumulate empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Feb 28, 2025
1 parent 65d85cc commit 9570419
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions grafast/dataplan-pg/src/steps/pgSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3699,9 +3699,14 @@ function buildJoin(inJoins: readonly PgSelectPlanJoin[]) {

function buildSelect(selects: readonly SQL[], asArray = false) {
if (asArray) {
return sql`select array[\n${sql.indent(
sql.join(selects, ",\n"),
)}\n]::text[]`;
if (selects.length < 1) {
// Cannot accumulate empty arrays
return sql`select array[null]::text[]`;
} else {
return sql`select array[\n${sql.indent(
sql.join(selects, ",\n"),
)}\n]::text[]`;
}
}
const fragmentsWithAliases = selects.map(
(frag, idx) => sql`${frag} as ${sql.identifier(String(idx))}`,
Expand Down

0 comments on commit 9570419

Please sign in to comment.