@@ -24,7 +24,11 @@ describe('Triggers', () => {
2424 source : 'todos' ,
2525 destination : tempTable ,
2626 columns : filteredColumns ,
27- operations : [ DiffTriggerOperation . INSERT , DiffTriggerOperation . UPDATE , DiffTriggerOperation . DELETE ]
27+ when : {
28+ [ DiffTriggerOperation . INSERT ] : 'TRUE' ,
29+ [ DiffTriggerOperation . UPDATE ] : 'TRUE' ,
30+ [ DiffTriggerOperation . DELETE ] : 'TRUE'
31+ }
2832 } ) ;
2933
3034 const results = [ ] as TriggerDiffRecord [ ] ;
@@ -116,7 +120,6 @@ describe('Triggers', () => {
116120 when : {
117121 [ DiffTriggerOperation . INSERT ] : sanitizeSQL `json_extract(NEW.data, '$.list_id') = ${ sanitizeUUID ( firstList . id ) } `
118122 } ,
119- operations : [ DiffTriggerOperation . INSERT ] ,
120123 onChange : async ( context ) => {
121124 // Fetches the current state of todo records that were inserted during this diff window.
122125 const newTodos = await context . withDiff < Database [ 'todos' ] > ( /* sql */ `
@@ -193,8 +196,10 @@ describe('Triggers', () => {
193196 */
194197 await database . triggers . trackTableDiff ( {
195198 source : 'lists' ,
196- when : { [ DiffTriggerOperation . UPDATE ] : sanitizeSQL `NEW.id = ${ sanitizeUUID ( list . id ) } ` } ,
197- operations : [ DiffTriggerOperation . UPDATE , DiffTriggerOperation . DELETE ] ,
199+ when : {
200+ [ DiffTriggerOperation . UPDATE ] : sanitizeSQL `NEW.id = ${ sanitizeUUID ( list . id ) } ` ,
201+ [ DiffTriggerOperation . DELETE ] : 'TRUE'
202+ } ,
198203 onChange : async ( context ) => {
199204 // Fetches the todo records that were inserted during this diff
200205 const diffs = await context . withExtractedDiff < ExtractedTriggerDiffRecord < Database [ 'lists' ] > > ( /* sql */ `
@@ -305,7 +310,6 @@ describe('Triggers', () => {
305310 when : {
306311 [ DiffTriggerOperation . INSERT ] : sanitizeSQL `json_extract(NEW.data, '$.list_id') = ${ sanitizeUUID ( firstList . id ) } `
307312 } ,
308- operations : [ DiffTriggerOperation . INSERT ] ,
309313 onChange : async ( context ) => {
310314 // Fetches the todo records that were inserted during this diff
311315 const newTodos = await context . withDiff < Database [ 'todos' ] > ( /* sql */ `
@@ -395,7 +399,6 @@ describe('Triggers', () => {
395399 when : {
396400 [ DiffTriggerOperation . INSERT ] : sanitizeSQL `json_extract(NEW.data, '$.list_id') = ${ sanitizeUUID ( firstList . id ) } `
397401 } ,
398- operations : [ DiffTriggerOperation . INSERT ] ,
399402 onChange : async ( context ) => {
400403 // Fetches the content of the records at the time of the operation
401404 const extractedDiff = await context . withExtractedDiff < { content : string ; operation : DiffTriggerOperation } > (
@@ -456,7 +459,11 @@ describe('Triggers', () => {
456459
457460 await database . triggers . trackTableDiff ( {
458461 source : 'todos' ,
459- operations : [ DiffTriggerOperation . INSERT , DiffTriggerOperation . UPDATE , DiffTriggerOperation . DELETE ] ,
462+ when : {
463+ [ DiffTriggerOperation . INSERT ] : 'TRUE' ,
464+ [ DiffTriggerOperation . UPDATE ] : 'TRUE' ,
465+ [ DiffTriggerOperation . DELETE ] : 'TRUE'
466+ } ,
460467 // Only track the row ids
461468 columns : [ ] ,
462469 onChange : async ( context ) => {
@@ -535,7 +542,11 @@ describe('Triggers', () => {
535542
536543 await database . triggers . trackTableDiff ( {
537544 source : 'todos' ,
538- operations : [ DiffTriggerOperation . INSERT , DiffTriggerOperation . UPDATE , DiffTriggerOperation . DELETE ] ,
545+ when : {
546+ [ DiffTriggerOperation . INSERT ] : 'TRUE' ,
547+ [ DiffTriggerOperation . UPDATE ] : 'TRUE' ,
548+ [ DiffTriggerOperation . DELETE ] : 'TRUE'
549+ } ,
539550 columns : [ 'columnA' ] ,
540551 onChange : async ( context ) => {
541552 // Fetches the content of the records at the time of the operation
0 commit comments