Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 7123cf8

Browse files
committed
fix: escape columns in columns query param
1 parent 4de56c2 commit 7123cf8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/lib/PostgrestQueryBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default class PostgrestQueryBuilder<T> extends PostgrestBuilder<T> {
110110
if (Array.isArray(values)) {
111111
const columns = values.reduce((acc, x) => acc.concat(Object.keys(x)), [] as string[])
112112
if (columns.length > 0) {
113-
const uniqueColumns = [...new Set(columns)]
113+
const uniqueColumns = [...new Set(columns)].map((column) => `"${column}"`)
114114
this.url.searchParams.set('columns', uniqueColumns.join(','))
115115
}
116116
}

test/basic.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ describe("insert, update, delete with count: 'exact'", () => {
270270

271271
test('insert includes columns param', async () => {
272272
const client = postgrest.from('users').insert([{ foo: 1 }, { bar: 2 }])
273-
expect((client as any).url.searchParams.get('columns')).toMatchInlineSnapshot(`"foo,bar"`)
273+
expect((client as any).url.searchParams.get('columns')).toMatchInlineSnapshot(
274+
`"\\"foo\\",\\"bar\\""`
275+
)
274276
})
275277

276278
test('insert w/ empty body has no columns param', async () => {

0 commit comments

Comments
 (0)