From cf14f43f0d9a3535d57e10d5edf1474612f16232 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Wed, 1 Jun 2022 03:18:26 +0800 Subject: [PATCH] feat: use undefined as bottom value instead of null BREAKING CHANGE: use undefined as bottom value instead of null --- src/PostgrestBuilder.ts | 17 +-- src/PostgrestClient.ts | 4 +- src/PostgrestFilterBuilder.ts | 5 +- src/PostgrestQueryBuilder.ts | 20 +-- src/types.ts | 13 +- test/__snapshots__/index.test.ts.snap | 198 +++++++++++++------------- test/basic.ts | 4 +- test/filters.ts | 112 +++++++-------- test/transforms.ts | 8 +- 9 files changed, 188 insertions(+), 193 deletions(-) diff --git a/src/PostgrestBuilder.ts b/src/PostgrestBuilder.ts index 7f0d00c3..6df306d5 100644 --- a/src/PostgrestBuilder.ts +++ b/src/PostgrestBuilder.ts @@ -41,10 +41,7 @@ export default abstract class PostgrestBuilder implements PromiseLike implements PromiseLike { - let error = null - let data = null - let count = null + let error = undefined + let data = undefined + let count = undefined let status = res.status let statusText = res.statusText @@ -112,7 +109,7 @@ export default abstract class PostgrestBuilder implements PromiseLike implements PromiseLike = {}, { head = false, - count = null, + count, }: { head?: boolean - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' } = {} ): PostgrestFilterBuilder { let method: 'HEAD' | 'POST' diff --git a/src/PostgrestFilterBuilder.ts b/src/PostgrestFilterBuilder.ts index b1d60cd5..6b40de7a 100644 --- a/src/PostgrestFilterBuilder.ts +++ b/src/PostgrestFilterBuilder.ts @@ -314,10 +314,7 @@ export default class PostgrestFilterBuilder extends PostgrestTransformBuilder textSearch( column: keyof T, query: string, - { - config, - type = null, - }: { config?: string; type?: 'plain' | 'phrase' | 'websearch' | null } = {} + { config, type }: { config?: string; type?: 'plain' | 'phrase' | 'websearch' } = {} ): this { let typePart = '' if (type === 'plain') { diff --git a/src/PostgrestQueryBuilder.ts b/src/PostgrestQueryBuilder.ts index 9f08c257..69b032f2 100644 --- a/src/PostgrestQueryBuilder.ts +++ b/src/PostgrestQueryBuilder.ts @@ -39,10 +39,10 @@ export default class PostgrestQueryBuilder extends PostgrestBuilder { columns = '*', { head = false, - count = null, + count, }: { head?: boolean - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' } = {} ): PostgrestFilterBuilder { this.method = 'GET' @@ -81,11 +81,11 @@ export default class PostgrestQueryBuilder extends PostgrestBuilder { insert( values: Partial | Partial[], { - count = null, + count, returning = 'minimal', }: { returning?: 'minimal' | 'representation' - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' } = {} ): PostgrestFilterBuilder { this.method = 'POST' @@ -125,13 +125,13 @@ export default class PostgrestQueryBuilder extends PostgrestBuilder { values: Partial | Partial[], { onConflict, - count = null, + count, returning = 'minimal', ignoreDuplicates = false, }: { onConflict?: string returning?: 'minimal' | 'representation' - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' ignoreDuplicates?: boolean } = {} ): PostgrestFilterBuilder { @@ -166,11 +166,11 @@ export default class PostgrestQueryBuilder extends PostgrestBuilder { update( values: Partial, { - count = null, + count, returning = 'minimal', }: { returning?: 'minimal' | 'representation' - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' } = {} ): PostgrestFilterBuilder { this.method = 'PATCH' @@ -194,11 +194,11 @@ export default class PostgrestQueryBuilder extends PostgrestBuilder { * @param options.returning By default deleted rows are NOT returned. Set this to 'representation' to return deleted rows. */ delete({ - count = null, + count, returning = 'minimal', }: { returning?: 'minimal' | 'representation' - count?: null | 'exact' | 'planned' | 'estimated' + count?: 'exact' | 'planned' | 'estimated' } = {}): PostgrestFilterBuilder { this.method = 'DELETE' const prefersHeaders = [`return=${returning}`] diff --git a/src/types.ts b/src/types.ts index 87242859..c14ac230 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,22 +23,23 @@ interface PostgrestResponseBase { } interface PostgrestResponseSuccess extends PostgrestResponseBase { - error: null + error: undefined data: T[] - count: number | null + count: number | undefined } interface PostgrestResponseFailure extends PostgrestResponseBase { error: PostgrestError - data: null - count: null + data: undefined + count: undefined } export type PostgrestResponse = PostgrestResponseSuccess | PostgrestResponseFailure interface PostgrestSingleResponseSuccess extends PostgrestResponseBase { - error: null + error: undefined data: T + count: number | undefined } export type PostgrestSingleResponse = | PostgrestSingleResponseSuccess | PostgrestResponseFailure -export type PostgrestMaybeSingleResponse = PostgrestSingleResponse +export type PostgrestMaybeSingleResponse = PostgrestSingleResponse diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index be135b8a..90c35fce 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Prefer: return=minimal 1`] = `null`; +exports[`Prefer: return=minimal 1`] = `undefined`; exports[`allow ordering on JSON column 1`] = ` Array [ @@ -37,7 +37,7 @@ Array [ exports[`basic insert, update, delete basic delete 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 2, @@ -61,7 +61,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -69,7 +69,7 @@ Object { exports[`basic insert, update, delete basic delete 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -86,7 +86,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -94,7 +94,7 @@ Object { exports[`basic insert, update, delete basic insert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -104,7 +104,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -112,7 +112,7 @@ Object { exports[`basic insert, update, delete basic insert 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -136,7 +136,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -144,7 +144,7 @@ Object { exports[`basic insert, update, delete basic update 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 2, @@ -168,7 +168,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -176,7 +176,7 @@ Object { exports[`basic insert, update, delete basic update 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -214,7 +214,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -222,7 +222,7 @@ Object { exports[`basic insert, update, delete bulk insert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -239,7 +239,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -247,7 +247,7 @@ Object { exports[`basic insert, update, delete bulk insert 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -285,7 +285,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -293,7 +293,7 @@ Object { exports[`basic insert, update, delete upsert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 2, @@ -303,7 +303,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -311,7 +311,7 @@ Object { exports[`basic insert, update, delete upsert 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -335,7 +335,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -343,7 +343,7 @@ Object { exports[`basic select table 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -374,17 +374,17 @@ Object { "username": "dragarcia", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } `; -exports[`don't mutate PostgrestClient.headers 1`] = `null`; +exports[`don't mutate PostgrestClient.headers 1`] = `undefined`; exports[`embedded filters embedded eq 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -407,7 +407,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -415,7 +415,7 @@ Object { exports[`embedded filters embedded or 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -445,7 +445,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -453,7 +453,7 @@ Object { exports[`embedded filters embedded or with and 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -483,7 +483,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -491,7 +491,7 @@ Object { exports[`embedded select 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -521,7 +521,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -529,7 +529,7 @@ Object { exports[`embedded transforms embedded limit 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -552,7 +552,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -560,7 +560,7 @@ Object { exports[`embedded transforms embedded order 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -590,7 +590,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -598,7 +598,7 @@ Object { exports[`embedded transforms embedded order on multiple columns 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -628,7 +628,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -636,7 +636,7 @@ Object { exports[`embedded transforms embedded range 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "messages": Array [ @@ -659,7 +659,7 @@ Object { "messages": Array [], }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -667,9 +667,9 @@ Object { exports[`ignoreDuplicates upsert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -708,7 +708,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -716,7 +716,7 @@ Object { exports[`insert, update, delete with count: 'exact' basic delete count: 'exact' 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -733,7 +733,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -758,7 +758,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -766,7 +766,7 @@ Object { exports[`insert, update, delete with count: 'exact' bulk insert with count: 'exact' 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -811,7 +811,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -829,7 +829,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -837,7 +837,7 @@ Object { exports[`insert, update, delete with count: 'exact' insert with count: 'exact' 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -861,7 +861,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -900,7 +900,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -908,7 +908,7 @@ Object { exports[`insert, update, delete with count: 'exact' update with count: 'exact' 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -953,7 +953,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -971,7 +971,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -979,7 +979,7 @@ Object { exports[`insert, update, delete with count: 'exact' upsert with count: 'exact' 2`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 1, @@ -1010,7 +1010,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1018,7 +1018,7 @@ Object { exports[`limit 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -1028,7 +1028,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1036,9 +1036,9 @@ Object { exports[`maybeSingle 1`] = ` Object { - "count": null, - "data": null, - "error": null, + "count": undefined, + "data": undefined, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1046,8 +1046,8 @@ Object { exports[`missing table 1`] = ` Object { - "count": null, - "data": null, + "count": undefined, + "data": undefined, "error": Object { "code": "42P01", "details": null, @@ -1061,7 +1061,7 @@ Object { exports[`on_conflict insert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[20,30)", @@ -1071,7 +1071,7 @@ Object { "username": "dragarcia", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -1079,7 +1079,7 @@ Object { exports[`order 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -1110,7 +1110,7 @@ Object { "username": "awailas", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1118,7 +1118,7 @@ Object { exports[`order on multiple columns 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "channel_id": 2, @@ -1135,7 +1135,7 @@ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1143,7 +1143,7 @@ Object { exports[`range 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[25,35)", @@ -1167,7 +1167,7 @@ Object { "username": "dragarcia", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1175,9 +1175,9 @@ Object { exports[`rpc 1`] = ` Object { - "count": null, + "count": undefined, "data": "ONLINE", - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1185,9 +1185,9 @@ Object { exports[`rpc returns void 1`] = ` Object { - "count": null, + "count": undefined, "data": null, - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1197,7 +1197,7 @@ exports[`rpc with count: 'exact' 1`] = ` Object { "count": 1, "data": "ONLINE", - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1206,8 +1206,8 @@ Object { exports[`rpc with head:true, count:exact 1`] = ` Object { "count": 1, - "data": null, - "error": null, + "data": undefined, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1215,13 +1215,13 @@ Object { exports[`select on insert 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", }, ], - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -1229,13 +1229,13 @@ Object { exports[`select on rpc 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1274,7 +1274,7 @@ Object { "username": "dragarcia", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1282,9 +1282,9 @@ Object { exports[`select with head:true 1`] = ` Object { - "count": null, - "data": null, - "error": null, + "count": undefined, + "data": undefined, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1293,8 +1293,8 @@ Object { exports[`select with head:true, count:estimated 1`] = ` Object { "count": Any, - "data": null, - "error": null, + "data": undefined, + "error": undefined, "status": 206, "statusText": "Partial Content", } @@ -1303,8 +1303,8 @@ Object { exports[`select with head:true, count:exact 1`] = ` Object { "count": 4, - "data": null, - "error": null, + "data": undefined, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1313,8 +1313,8 @@ Object { exports[`select with head:true, count:planned 1`] = ` Object { "count": Any, - "data": null, - "error": null, + "data": undefined, + "error": undefined, "status": 206, "statusText": "Partial Content", } @@ -1322,7 +1322,7 @@ Object { exports[`single 1`] = ` Object { - "count": null, + "count": undefined, "data": Object { "age_range": "[1,2)", "catchphrase": "'cat' 'fat'", @@ -1330,7 +1330,7 @@ Object { "status": "ONLINE", "username": "supabot", }, - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -1338,7 +1338,7 @@ Object { exports[`single on insert 1`] = ` Object { - "count": null, + "count": undefined, "data": Object { "age_range": null, "catchphrase": null, @@ -1346,7 +1346,7 @@ Object { "status": "ONLINE", "username": "foo", }, - "error": null, + "error": undefined, "status": 201, "statusText": "Created", } @@ -1354,7 +1354,7 @@ Object { exports[`switch schema 1`] = ` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -1387,7 +1387,7 @@ Object { "username": "leroyjenkins", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } diff --git a/test/basic.ts b/test/basic.ts index c931209e..c2c3509c 100644 --- a/test/basic.ts +++ b/test/basic.ts @@ -398,9 +398,9 @@ test('select with no match', async () => { const res = await postgrest.from('users').select().eq('username', 'missing') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } diff --git a/test/filters.ts b/test/filters.ts index 140d7ddf..0fa2ed8e 100644 --- a/test/filters.ts +++ b/test/filters.ts @@ -6,7 +6,7 @@ test('not', async () => { const res = await postgrest.from('users').select('status').not('status', 'eq', 'OFFLINE') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", @@ -18,7 +18,7 @@ test('not', async () => { "status": "ONLINE", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -32,7 +32,7 @@ test('or', async () => { .or('status.eq.OFFLINE,username.eq.supabot') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", @@ -43,7 +43,7 @@ test('or', async () => { "username": "kiwicopple", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -54,13 +54,13 @@ test('eq', async () => { const res = await postgrest.from('users').select('username').eq('username', 'supabot') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -71,7 +71,7 @@ test('neq', async () => { const res = await postgrest.from('users').select('username').neq('username', 'supabot') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "username": "kiwicopple", @@ -83,7 +83,7 @@ test('neq', async () => { "username": "dragarcia", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -94,13 +94,13 @@ test('gt', async () => { const res = await postgrest.from('messages').select('id').gt('id', 1) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "id": 2, }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -111,7 +111,7 @@ test('gte', async () => { const res = await postgrest.from('messages').select('id').gte('id', 1) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "id": 1, @@ -120,7 +120,7 @@ test('gte', async () => { "id": 2, }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -131,13 +131,13 @@ test('lt', async () => { const res = await postgrest.from('messages').select('id').lt('id', 2) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "id": 1, }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -148,7 +148,7 @@ test('lte', async () => { const res = await postgrest.from('messages').select('id').lte('id', 2) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "id": 1, @@ -157,7 +157,7 @@ test('lte', async () => { "id": 2, }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -168,13 +168,13 @@ test('like', async () => { const res = await postgrest.from('users').select('username').like('username', '%supa%') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -185,13 +185,13 @@ test('ilike', async () => { const res = await postgrest.from('users').select('username').ilike('username', '%SUPA%') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -202,7 +202,7 @@ test('is', async () => { const res = await postgrest.from('users').select('data').is('data', null) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "data": null, @@ -217,7 +217,7 @@ test('is', async () => { "data": null, }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -228,7 +228,7 @@ test('in', async () => { const res = await postgrest.from('users').select('status').in('status', ['ONLINE', 'OFFLINE']) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", @@ -243,7 +243,7 @@ test('in', async () => { "status": "ONLINE", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -254,13 +254,13 @@ test('contains', async () => { const res = await postgrest.from('users').select('age_range').contains('age_range', '[1,2)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -271,13 +271,13 @@ test('containedBy', async () => { const res = await postgrest.from('users').select('age_range').containedBy('age_range', '[1,2)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -288,13 +288,13 @@ test('rangeLt', async () => { const res = await postgrest.from('users').select('age_range').rangeLt('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -305,7 +305,7 @@ test('rangeGt', async () => { const res = await postgrest.from('users').select('age_range').rangeGt('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[25,35)", @@ -314,7 +314,7 @@ test('rangeGt', async () => { "age_range": "[25,35)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -325,7 +325,7 @@ test('rangeGte', async () => { const res = await postgrest.from('users').select('age_range').rangeGte('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[25,35)", @@ -337,7 +337,7 @@ test('rangeGte', async () => { "age_range": "[20,30)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -348,13 +348,13 @@ test('rangeLte', async () => { const res = await postgrest.from('users').select('age_range').rangeLte('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -365,7 +365,7 @@ test('rangeAdjacent', async () => { const res = await postgrest.from('users').select('age_range').rangeAdjacent('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -377,7 +377,7 @@ test('rangeAdjacent', async () => { "age_range": "[25,35)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -388,13 +388,13 @@ test('overlaps', async () => { const res = await postgrest.from('users').select('age_range').overlaps('age_range', '[2,25)') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[20,30)", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -408,13 +408,13 @@ test('textSearch', async () => { .textSearch('catchphrase', `'fat' & 'cat'`, { config: 'english' }) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "catchphrase": "'cat' 'fat'", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -428,13 +428,13 @@ test('textSearch with plainto_tsquery', async () => { .textSearch('catchphrase', `'fat' & 'cat'`, { config: 'english', type: 'plain' }) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "catchphrase": "'cat' 'fat'", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -448,7 +448,7 @@ test('textSearch with phraseto_tsquery', async () => { .textSearch('catchphrase', 'cat', { config: 'english', type: 'phrase' }) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "catchphrase": "'cat' 'fat'", @@ -457,7 +457,7 @@ test('textSearch with phraseto_tsquery', async () => { "catchphrase": "'bat' 'cat'", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -471,13 +471,13 @@ test('textSearch with websearch_to_tsquery', async () => { .textSearch('catchphrase', `'fat' & 'cat'`, { config: 'english', type: 'websearch' }) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "catchphrase": "'cat' 'fat'", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -495,7 +495,7 @@ test('multiple filters', async () => { .textSearch('catchphrase', 'cat') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "age_range": "[1,2)", @@ -505,7 +505,7 @@ test('multiple filters', async () => { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -516,13 +516,13 @@ test('filter', async () => { const res = await postgrest.from('users').select('username').filter('username', 'eq', 'supabot') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -536,14 +536,14 @@ test('match', async () => { .match({ username: 'supabot', status: 'ONLINE' }) expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [ Object { "status": "ONLINE", "username": "supabot", }, ], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -556,9 +556,9 @@ test('filter on rpc', async () => { .neq('status', 'ONLINE') expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": Array [], - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } diff --git a/test/transforms.ts b/test/transforms.ts index 8aa9399d..498907a1 100644 --- a/test/transforms.ts +++ b/test/transforms.ts @@ -69,13 +69,13 @@ test('csv', async () => { const res = await postgrest.from('users').select().csv() expect(res).toMatchInlineSnapshot(` Object { - "count": null, + "count": undefined, "data": "username,data,age_range,status,catchphrase supabot,,\\"[1,2)\\",ONLINE,\\"'cat' 'fat'\\" kiwicopple,,\\"[25,35)\\",OFFLINE,\\"'bat' 'cat'\\" awailas,,\\"[25,35)\\",ONLINE,\\"'bat' 'rat'\\" dragarcia,,\\"[20,30)\\",ONLINE,\\"'fat' 'rat'\\"", - "error": null, + "error": undefined, "status": 200, "statusText": "OK", } @@ -88,8 +88,8 @@ test('abort signal', async () => { const res = await postgrest.from('users').select().abortSignal(ac.signal) expect(res).toMatchInlineSnapshot(` Object { - "count": null, - "data": null, + "count": undefined, + "data": undefined, "error": Object { "code": "", "details": "",