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

Commit 4de56c2

Browse files
committed
test: add no match select case
1 parent 34ba10f commit 4de56c2

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

test/basic.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,17 @@ test('insert w/ empty body has no columns param', async () => {
277277
const client = postgrest.from('users').insert([{}, {}])
278278
expect((client as any).url.searchParams.has('columns')).toBeFalsy()
279279
})
280+
281+
test('select with no match', async () => {
282+
const res = await postgrest.from('users').select().eq('username', 'missing')
283+
expect(res).toMatchInlineSnapshot(`
284+
Object {
285+
"body": Array [],
286+
"count": null,
287+
"data": Array [],
288+
"error": null,
289+
"status": 200,
290+
"statusText": "OK",
291+
}
292+
`)
293+
})

test/filters.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,23 @@ test('neq', async () => {
128128
})
129129

130130
test('gt', async () => {
131-
const res = await postgrest.from('messages').select('').gt('id', 1)
131+
const res = await postgrest.from('messages').select('id').gt('id', 1)
132132
expect(res).toMatchInlineSnapshot(`
133133
Object {
134-
"body": null,
134+
"body": Array [
135+
Object {
136+
"id": 2,
137+
},
138+
],
135139
"count": null,
136-
"data": null,
137-
"error": Object {
138-
"details": "unexpected end of input expecting field name (* or [a..z0..9_]) or \\"*\\"",
139-
"message": "\\"failed to parse select parameter ()\\" (line 1, column 1)",
140-
},
141-
"status": 400,
142-
"statusText": "Bad Request",
140+
"data": Array [
141+
Object {
142+
"id": 2,
143+
},
144+
],
145+
"error": null,
146+
"status": 200,
147+
"statusText": "OK",
143148
}
144149
`)
145150
})

0 commit comments

Comments
 (0)