1
1
/* eslint-disable max-lines */
2
- import { isPlainObject } from '../utils-hoist' ;
2
+ import { logger , isPlainObject } from '../utils-hoist' ;
3
3
4
4
import type { Span , IntegrationFn } from '../types-hoist' ;
5
5
import { setHttpStatus , startInactiveSpan } from '../tracing' ;
@@ -57,10 +57,20 @@ export interface SupabaseBreadcrumb {
57
57
export const AVAILABLE_OPERATIONS = [ 'select' , 'insert' , 'upsert' , 'update' , 'delete' ] ;
58
58
59
59
export const FILTER_MAPPINGS = {
60
+ eq : 'eq' ,
61
+ neq : 'neq' ,
62
+ gt : 'gt' ,
63
+ gte : 'gte' ,
64
+ lt : 'lt' ,
65
+ lte : 'lte' ,
66
+ like : 'like' ,
60
67
'like(all)' : 'likeAllOf' ,
61
68
'like(any)' : 'likeAnyOf' ,
69
+ ilike : 'ilike' ,
62
70
'ilike(all)' : 'ilikeAllOf' ,
63
71
'ilike(any)' : 'ilikeAnyOf' ,
72
+ is : 'is' ,
73
+ in : 'in' ,
64
74
cs : 'contains' ,
65
75
cd : 'containedBy' ,
66
76
sr : 'rangeGt' ,
@@ -69,6 +79,11 @@ export const FILTER_MAPPINGS = {
69
79
nxr : 'rangeLte' ,
70
80
adj : 'rangeAdjacent' ,
71
81
ov : 'overlaps' ,
82
+ fts : '' ,
83
+ plfts : 'plain' ,
84
+ phfts : 'phrase' ,
85
+ wfts : 'websearch' ,
86
+ not : 'not' ,
72
87
} ;
73
88
74
89
const instrumented = new Map ( ) ;
@@ -135,7 +150,7 @@ export function translateFiltersIntoMethods(key: string, query: string): string
135
150
} else if ( filter ?. startsWith ( 'wfts' ) ) {
136
151
method = 'textSearch[websearch]' ;
137
152
} else {
138
- method = ( filter && FILTER_MAPPINGS [ filter as keyof typeof FILTER_MAPPINGS ] ) || filter || 'filter' ;
153
+ method = ( filter && FILTER_MAPPINGS [ filter as keyof typeof FILTER_MAPPINGS ] ) || 'filter' ;
139
154
}
140
155
141
156
return `${ method } (${ key } , ${ value . join ( '.' ) } )` ;
@@ -359,6 +374,8 @@ function instrumentPostgrestQueryBuilder(PostgrestQueryBuilder: new () => Postgr
359
374
const rv = Reflect . apply ( target , thisArg , argumentsList ) ;
360
375
const PostgrestFilterBuilder = ( rv as PostgrestFilterBuilder ) . constructor ;
361
376
377
+ logger . log ( `Instrumenting ${ operation } operation's PostgrestFilterBuilder` ) ;
378
+
362
379
instrumentPostgrestFilterBuilder ( PostgrestFilterBuilder ) ;
363
380
364
381
return rv ;
0 commit comments