Skip to content

Commit 5c22e41

Browse files
authored
feat: warn early if placeholders will be exhausted (#632)
1 parent e862aad commit 5c22e41

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/pg-sql2/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ export function compile(sql: SQLQuery | SQLNode): QueryConfig {
155155
}
156156

157157
const text = sqlFragments.join("");
158+
if (values.length > 65535) {
159+
throw new Error(
160+
"PostgreSQL allows the use of up to 65535 placeholders; but your statement wants to use ${values.length} placeholders. To solve this issue you could split the statement into multiple statements, or pass more values into a single placeholder by using JSON, arrays, or similar techniques."
161+
);
162+
}
158163
return {
159164
text,
160165
values,

0 commit comments

Comments
 (0)