Skip to content

Commit 4110185

Browse files
committed
chore: use helper for feature flag from version
1 parent ab5b06d commit 4110185

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export type {
2929
PostgrestSingleResponse,
3030
PostgrestMaybeSingleResponse,
3131
ClientServerOptions,
32-
PostgRESTVersion,
3332
} from './types'
3433
// https://github.com/supabase/postgrest-js/issues/551
3534
// To be replaced with a helper type that only uses public types

src/select-query-parser/result.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import {
2121
SelectQueryError,
2222
} from './utils'
2323

24+
export type SpreadOnManyEnabled<postgrestVersion extends number | undefined> =
25+
postgrestVersion extends 13 ? true : false
26+
2427
/**
2528
* Main entry point for constructing the result type of a PostgREST query.
2629
*
@@ -445,7 +448,7 @@ type ProcessSpreadNode<
445448
? Result extends SelectQueryError<infer E>
446449
? SelectQueryError<E>
447450
: ExtractFirstProperty<Result> extends unknown[]
448-
? ClientOptions['postgrestVersion'] extends 13 // Spread over an many-to-many relationship, turn all the result fields into correlated arrays
451+
? SpreadOnManyEnabled<ClientOptions['postgrestVersion']> extends true // Spread over an many-to-many relationship, turn all the result fields into correlated arrays
449452
? ProcessManyToManySpreadNodeResult<Result>
450453
: {
451454
[K in Spread['target']['name']]: SelectQueryError<`"${RelationName}" and "${Spread['target']['name']}" do not form a many-to-one or one-to-one relationship spread not possible`>

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export type GenericSchema = {
7171
Functions: Record<string, GenericFunction>
7272
}
7373

74-
export type PostgRESTVersion = 12 | 13
74+
type PostgRESTMajorVersion = number
7575
export type ClientServerOptions = {
76-
postgrestVersion?: PostgRESTVersion
76+
postgrestVersion?: PostgRESTMajorVersion
7777
}
7878

7979
export type DatabaseWithOptions<Database, Options extends ClientServerOptions> = {

0 commit comments

Comments
 (0)