Skip to content

Commit

Permalink
feat: warn early if placeholders will be exhausted (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jul 29, 2020
1 parent e862aad commit 5c22e41
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/pg-sql2/src/index.ts
Expand Up @@ -155,6 +155,11 @@ export function compile(sql: SQLQuery | SQLNode): QueryConfig {
}

const text = sqlFragments.join("");
if (values.length > 65535) {
throw new Error(
"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."
);
}
return {
text,
values,
Expand Down

0 comments on commit 5c22e41

Please sign in to comment.