File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ type FilterOperator =
26
26
| 'phfts'
27
27
| 'wfts'
28
28
29
+ export type IsStringOperator < Path extends string > = Path extends `${string } ->>${string } `
30
+ ? true
31
+ : false
32
+
29
33
// Match relationship filters with `table.column` syntax and resolve underlying
30
34
// column value. If not matched, fallback to generic type.
31
35
// TODO: Validate the relationship itself ala select-query-parser. Currently we
@@ -41,9 +45,11 @@ type ResolveFilterValue<
41
45
: ResolveFilterRelationshipValue < Schema , RelationshipTable , Remainder >
42
46
: ColumnName extends keyof Row
43
47
? Row [ ColumnName ]
44
- : // If the column selection is a jsonpath like `data->value` we attempt to match
48
+ : // If the column selection is a jsonpath like `data->value` or `data->>value` we attempt to match
45
49
// the expected type with the parsed custom json type
46
- JsonPathToType < Row , JsonPathToAccessor < ColumnName > > extends infer JsonPathValue
50
+ IsStringOperator < ColumnName > extends true
51
+ ? string
52
+ : JsonPathToType < Row , JsonPathToAccessor < ColumnName > > extends infer JsonPathValue
47
53
? JsonPathValue extends never
48
54
? never
49
55
: JsonPathValue
Original file line number Diff line number Diff line change @@ -280,7 +280,13 @@ const postgrestOverrideTypes = new PostgrestClient<DatabaseOverride>('http://loc
280
280
const resIn = await postgrestOverrideTypes
281
281
. from ( 'foo' )
282
282
. select ( 'id, bar, baz' )
283
- . in ( 'bar->version' , [ 1 , 32 ] )
283
+ . in ( 'bar->version' , [ 31 ] )
284
+ . single ( )
285
+ await postgrestOverrideTypes
286
+ . from ( 'foo' )
287
+ . select ( 'id, bar, baz' )
288
+ // the type become a string when using the string json accessor operator
289
+ . in ( 'bar->>version' , [ 'something' ] )
284
290
. single ( )
285
291
286
292
if ( resIn . error ) {
You can’t perform that action at this time.
0 commit comments