File tree Expand file tree Collapse file tree
apps/sim/lib/core/idempotency Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,6 +154,8 @@ describe('IdempotencyService in-progress deadlines', () => {
154154
155155 const conflictOptions = dbChainMockFns . onConflictDoUpdate . mock . calls [ 0 ] ?. [ 0 ]
156156 const setWhere = JSON . stringify ( conflictOptions ?. setWhere )
157+ expect ( setWhere ) . toContain ( 'json_typeof' )
158+ expect ( setWhere ) . not . toContain ( 'jsonb_typeof' )
157159 expect ( setWhere ) . toContain ( 'IS DISTINCT FROM' )
158160 expect ( setWhere ) . toContain ( 'in-progress' )
159161 } )
@@ -229,7 +231,8 @@ describe('IdempotencyService in-progress deadlines', () => {
229231 service . executeWithIdempotency ( 'provider' , 'delivery-retry-db' , vi . fn ( ) )
230232 ) . resolves . toBe ( 'new-owner-result' )
231233
232- const condition = dbChainMockFns . where . mock . calls . at ( - 1 ) ?. [ 0 ]
233- expect ( JSON . stringify ( condition ) ) . toContain ( 'retry me' )
234+ const condition = JSON . stringify ( dbChainMockFns . where . mock . calls . at ( - 1 ) ?. [ 0 ] )
235+ expect ( condition ) . toContain ( 'retry me' )
236+ expect ( condition . match ( / : : j s o n b / g) ) . toHaveLength ( 2 )
234237 } )
235238} )
Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ export class IdempotencyService {
327327 const expiredBefore = new Date ( now . getTime ( ) - this . config . ttlSeconds * 1000 )
328328 const inProgressClaimExpired = sql `COALESCE(
329329 CASE
330- WHEN jsonb_typeof (${ idempotencyKey . result } -> 'inProgressExpiresAt') = 'number'
330+ WHEN json_typeof (${ idempotencyKey . result } -> 'inProgressExpiresAt') = 'number'
331331 THEN (${ idempotencyKey . result } ->> 'inProgressExpiresAt')::double precision
332332 END,
333333 EXTRACT(EPOCH FROM ${ idempotencyKey . createdAt } ) * 1000 + ${ this . config . inProgressTtlSeconds * 1000 }
@@ -548,7 +548,7 @@ export class IdempotencyService {
548548 : fence ?. observedResult
549549 ? and (
550550 eq ( idempotencyKey . key , normalizedKey ) ,
551- sql `${ idempotencyKey . result } = ${ JSON . stringify ( fence . observedResult ) } ::jsonb`
551+ sql `${ idempotencyKey . result } ::jsonb = ${ JSON . stringify ( fence . observedResult ) } ::jsonb`
552552 )
553553 : eq ( idempotencyKey . key , normalizedKey )
554554 const deleted = await db
You can’t perform that action at this time.
0 commit comments