Skip to content

Commit 9570419

Browse files
committed
Cannot accumulate empty arrays
1 parent 65d85cc commit 9570419

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

grafast/dataplan-pg/src/steps/pgSelect.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,9 +3699,14 @@ function buildJoin(inJoins: readonly PgSelectPlanJoin[]) {
36993699

37003700
function buildSelect(selects: readonly SQL[], asArray = false) {
37013701
if (asArray) {
3702-
return sql`select array[\n${sql.indent(
3703-
sql.join(selects, ",\n"),
3704-
)}\n]::text[]`;
3702+
if (selects.length < 1) {
3703+
// Cannot accumulate empty arrays
3704+
return sql`select array[null]::text[]`;
3705+
} else {
3706+
return sql`select array[\n${sql.indent(
3707+
sql.join(selects, ",\n"),
3708+
)}\n]::text[]`;
3709+
}
37053710
}
37063711
const fragmentsWithAliases = selects.map(
37073712
(frag, idx) => sql`${frag} as ${sql.identifier(String(idx))}`,

0 commit comments

Comments
 (0)