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

Commit e3705ce

Browse files
committed
chore: use canary postgres-meta
1 parent 0b77a07 commit e3705ce

10 files changed

+24
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"type-check:test": "tsc --noEmit --project tsconfig.test.json",
5050
"db:clean": "cd test/db && docker compose down --volumes",
5151
"db:run": "cd test/db && docker compose up --detach && wait-for-localhost 3000",
52-
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && curl --location 'http://0.0.0.0:8080/generators/typescript?included_schemas=public,personal&detect_one_to_one_relationships=true' > ../types.generated.ts && node ../scripts/update-json-type.js && prettier --write ../types.generated.ts"
52+
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && wait-for-localhost 3000 && curl --location 'http://0.0.0.0:8080/generators/typescript?included_schemas=public,personal&detect_one_to_one_relationships=true' > ../types.generated.ts && node ../scripts/update-json-type.js && prettier --write ../types.generated.ts"
5353
},
5454
"dependencies": {
5555
"@supabase/node-fetch": "^2.6.14"

test/advanced_rpc.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { PostgrestClient } from '../src/index'
22
import { Database } from './types.override'
3-
import { expectType } from 'tsd'
4-
import { TypeEqual } from 'ts-expect'
3+
import { TypeEqual, expectType } from './types'
54
import { SelectQueryError } from '../src/select-query-parser/utils'
65
import { z } from 'zod'
76
import { RequiredDeep } from 'type-fest'
87

98
const REST_URL = 'http://localhost:3000'
10-
export const postgrest = new PostgrestClient<Database>(REST_URL)
9+
const postgrest = new PostgrestClient<Database>(REST_URL)
1110

1211
const MessagesWithoutBlurbSchema = z.object({
1312
channel_id: z.number(),
@@ -526,11 +525,11 @@ describe('advanced rpc', () => {
526525
test('should be able to filter before and after select rpc', async () => {
527526
const res = await postgrest
528527
.rpc('get_user_profile', {
529-
//@ts-expect-error will complain about missing the rest of the params
528+
//@ts-expect-error Type '{ username: string; }' is missing the following properties from type '{ age_range: unknown; catchphrase: unknown; data: unknown; status: "ONLINE" | "OFFLINE" | null; username: string; }': age_range, catchphrase, data, status
530529
user_row: { username: 'supabot' },
531530
})
532531
.select('id, username, users(username, catchphrase)')
533-
//@ts-expect-error will complain about missing the rest of the params
532+
//@ts-expect-error Property 'eq' does not exist on type
534533
.eq('username', 'nope')
535534

536535
expect(res).toMatchInlineSnapshot(`
@@ -544,7 +543,7 @@ describe('advanced rpc', () => {
544543
`)
545544
const res2 = await postgrest
546545
.rpc('get_user_profile', {
547-
//@ts-expect-error will complain about missing the rest of the params
546+
//@ts-expect-error Type '{ username: string; }' is missing the following properties from type
548547
user_row: { username: 'supabot' },
549548
})
550549
// should also be able to fitler before the select
@@ -562,7 +561,7 @@ describe('advanced rpc', () => {
562561
`)
563562
const res3 = await postgrest
564563
.rpc('get_user_profile', {
565-
//@ts-expect-error will complain about missing the rest of the params
564+
//@ts-expect-error Type '{ username: string; }' is missing the following properties from type
566565
user_row: { username: 'supabot' },
567566
})
568567
// should also be able to fitler before the select
@@ -830,7 +829,7 @@ describe('advanced rpc', () => {
830829

831830
test('polymorphic function with bool param', async () => {
832831
const res = await postgrest.rpc('polymorphic_function_with_different_return', {
833-
// @ts-expect-error should not have a function with a single unnamed params that isn't json/jsonb/text in types definitions
832+
// @ts-expect-error Type 'boolean' is not assignable to type 'string'
834833
'': true,
835834
})
836835
expect(res).toMatchInlineSnapshot(`
@@ -846,7 +845,7 @@ describe('advanced rpc', () => {
846845

847846
test('polymorphic function with unnamed int param', async () => {
848847
const res = await postgrest.rpc(
849-
// @ts-expect-error should not have a function with a single unnamed params that isn't json/jsonb/text in types definitions
848+
// @ts-expect-error Argument of type '"polymorphic_function_with_unnamed_integer"' is not assignable to parameter of type '"blurb_message" | "function_returning_row" | "function_returning_set_of_rows"
850849
'polymorphic_function_with_unnamed_integer',
851850
{
852851
'': 1,
@@ -1000,8 +999,8 @@ describe('advanced rpc', () => {
1000999
let result: Exclude<typeof res.data, null>
10011000
// TODO: there is no ways for now to distinguish between a valid optional argument or a missing one if the argument is unnamed
10021001
let expected: SelectQueryError<'Could not choose the best candidate function between: public.polymorphic_function_with_unnamed_default(), public.polymorphic_function_with_unnamed_default( => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved'>
1003-
//@ts-expect-error
1004-
expectType<TypeEqual<typeof result, typeof expected>>(true)
1002+
// this should be true
1003+
expectType<TypeEqual<typeof result, typeof expected>>(false)
10051004
expect(res).toMatchInlineSnapshot(`
10061005
Object {
10071006
"count": null,
@@ -1062,8 +1061,8 @@ describe('advanced rpc', () => {
10621061
let result: Exclude<typeof res.data, null>
10631062
// TODO: there is no ways for now to distinguish between a valid optional argument or a missing one if the argument is unnamed
10641063
let expected: SelectQueryError<'Could not choose the best candidate function between: public.polymorphic_function_with_unnamed_default_overload(), public.polymorphic_function_with_unnamed_default_overload( => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved'>
1065-
//@ts-expect-error
1066-
expectType<TypeEqual<typeof result, typeof expected>>(true)
1064+
// this should be true
1065+
expectType<TypeEqual<typeof result, typeof expected>>(false)
10671066
expect(res).toMatchInlineSnapshot(`
10681067
Object {
10691068
"count": null,
@@ -1100,7 +1099,7 @@ describe('advanced rpc', () => {
11001099

11011100
test('polymorphic function with unnamed default overload bool param', async () => {
11021101
const res = await postgrest.rpc('polymorphic_function_with_unnamed_default_overload', {
1103-
//@ts-expect-error
1102+
//@ts-expect-error Type 'boolean' is not assignable to type 'string'
11041103
'': true,
11051104
})
11061105
let result: Exclude<typeof res.data, null>

test/db/docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ services:
4141
POSTGRES_HOST: /var/run/postgresql
4242
POSTGRES_PORT: 5432
4343
pgmeta:
44-
# TODO: use postgres-meta once https://github.com/supabase/postgres-meta/pull/971 is published
45-
image: local-pg-meta
44+
image: supabase/postgres-meta:canary-pr-971-f1f23911f3feffdc8f033b5aaee0ccca0be39df1
4645
ports:
4746
- '8080:8080'
4847
environment:

test/embeded_functions_join.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { PostgrestClient } from '../src/index'
22
import { Database } from './types.override'
3-
import { expectType } from 'tsd'
4-
import { TypeEqual } from 'ts-expect'
3+
import { expectType, TypeEqual } from './types'
54
import { z } from 'zod'
65
import { RequiredDeep } from 'type-fest'
76

87
const REST_URL = 'http://localhost:3000'
9-
export const postgrest = new PostgrestClient<Database>(REST_URL)
8+
const postgrest = new PostgrestClient<Database>(REST_URL)
109

1110
describe('embeded functions select', () => {
1211
test('embeded_setof_function - function returning a setof embeded table', async () => {

test/relationships-aggregate-operations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expectType, TypeEqual } from './types'
44
import { z } from 'zod'
55

66
const REST_URL = 'http://localhost:3000'
7-
export const postgrest = new PostgrestClient<Database>(REST_URL)
7+
const postgrest = new PostgrestClient<Database>(REST_URL)
88

99
test('select with aggregate count function', async () => {
1010
const res = await postgrest.from('users').select('username, messages(count)').limit(1).single()

test/relationships-error-handling.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expectType, TypeEqual } from './types'
44
import { SelectQueryError } from '../src/select-query-parser/utils'
55

66
const REST_URL = 'http://localhost:3000'
7-
export const postgrest = new PostgrestClient<Database>(REST_URL)
7+
const postgrest = new PostgrestClient<Database>(REST_URL)
88

99
test('join over a 1-1 relation with both nullables and non-nullables fields with no hinting', async () => {
1010
const res = await postgrest

test/relationships-join-operations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { z } from 'zod'
55
import { RequiredDeep } from 'type-fest'
66

77
const REST_URL = 'http://localhost:3000'
8-
export const postgrest = new PostgrestClient<Database>(REST_URL)
8+
const postgrest = new PostgrestClient<Database>(REST_URL)
99
const userColumn: 'catchphrase' | 'username' = 'username'
1010

1111
// Zod schemas for common types

test/relationships-spread-operations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expectType, TypeEqual } from './types'
55
import { z } from 'zod'
66

77
const REST_URL = 'http://localhost:3000'
8-
export const postgrest = new PostgrestClient<Database>(REST_URL)
8+
const postgrest = new PostgrestClient<Database>(REST_URL)
99
const REST_URL_13 = 'http://localhost:3001'
1010
const postgrest13 = new PostgrestClient<Database, { PostgrestVersion: '13' }>(REST_URL_13)
1111
const postgrest13FromDatabaseTypes = new PostgrestClient<DatabaseWithOptions13>(REST_URL_13)

test/relationships.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Json } from '../src/select-query-parser/types'
66
import { RequiredDeep } from 'type-fest'
77

88
const REST_URL = 'http://localhost:3000'
9-
export const postgrest = new PostgrestClient<Database>(REST_URL)
9+
const postgrest = new PostgrestClient<Database>(REST_URL)
1010

1111
const UsersRowSchema = z.object({
1212
age_range: z.unknown().nullable(),

test/rpc.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { expectType, TypeEqual } from './types'
44
import { z } from 'zod'
55

66
const REST_URL = 'http://localhost:3000'
7-
export const postgrest = new PostgrestClient<Database>(REST_URL)
7+
const postgrest = new PostgrestClient<Database>(REST_URL)
88

9-
export const RPC_NAME = 'get_username_and_status'
9+
const RPC_NAME = 'get_username_and_status'
1010

1111
test('RPC call with no params', async () => {
1212
const res = await postgrest.rpc(RPC_NAME, { name_param: 'supabot' }).select()

0 commit comments

Comments
 (0)