Skip to content

Commit

Permalink
Mark a few of the pg-sql2 inputs as readonly (#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored Jan 28, 2025
2 parents e192e3f + 3b0f508 commit 18cd1ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/honest-goats-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"pg-sql2": patch
---

Some of the pg-sql2 inputs are now marked Readonly to indicate we won't mutate
them.
6 changes: 3 additions & 3 deletions utils/pg-sql2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function enforceValidNode(node: unknown, where?: string): SQL {
*/
export function compile(
sql: SQL,
options?: { placeholderValues?: Map<symbol, SQL> },
options?: { placeholderValues?: ReadonlyMap<symbol, SQL> },
): {
text: string;
values: SQLRawValue[];
Expand Down Expand Up @@ -806,7 +806,7 @@ export function literal(val: string | number | boolean | null): SQL {
* dealing with lists of SQL items, for example a dynamic list of columns or
* variadic SQL function arguments.
*/
export function join(items: Array<SQL>, separator = ""): SQL {
export function join(items: ReadonlyArray<SQL>, separator = ""): SQL {
if (!Array.isArray(items)) {
throw new Error(
`[pg-sql2] Invalid sql.join call - the first argument should be an array, but it was '${inspect(
Expand Down Expand Up @@ -1235,7 +1235,7 @@ export function replaceSymbol(
*/
function getSubstitute(
initialSymbol: symbol,
symbolSubstitutes?: Map<symbol, symbol>,
symbolSubstitutes?: ReadonlyMap<symbol, symbol>,
): symbol {
const path: symbol[] = [];
let symbol = initialSymbol;
Expand Down

0 comments on commit 18cd1ca

Please sign in to comment.