@@ -69,14 +69,14 @@ WITH updated_rows AS (
6969 SELECT b.row_type, b.row_id FROM ps_buckets AS buckets
7070 CROSS JOIN ps_oplog AS b ON b.bucket = buckets.id
7171 AND (b.op_id > buckets.last_applied_op)
72- UNION SELECT row_type, row_id FROM ps_updated_rows
72+ UNION ALL SELECT row_type, row_id FROM ps_updated_rows
7373)
7474
7575-- 3. Group the objects from different buckets together into a single one (ops).
7676SELECT b.row_type as type,
7777 b.row_id as id,
7878 r.data as data,
79- json_group_array (r.bucket) as buckets,
79+ count (r.bucket) as buckets,
8080 /* max() affects which row is used for 'data' */
8181 max(r.op_id) as op_id
8282-- 2. Find *all* current ops over different buckets for those objects (oplog r).
@@ -94,15 +94,15 @@ GROUP BY b.row_type, b.row_id",
9494 while statement. step ( ) . into_db_result ( db) ? == ResultCode :: ROW {
9595 let type_name = statement. column_text ( 0 ) ?;
9696 let id = statement. column_text ( 1 ) ?;
97- let buckets = statement. column_text ( 3 ) ?;
97+ let buckets = statement. column_int ( 3 ) ?;
9898 let data = statement. column_text ( 2 ) ;
9999
100100 let table_name = internal_table_name ( type_name) ;
101101
102102 if tables. contains ( & table_name) {
103103 let quoted = quote_internal_name ( type_name, false ) ;
104104
105- if buckets == "[]" || buckets == "[null]" {
105+ if buckets == 0 {
106106 // DELETE
107107 let delete_statement = db
108108 . prepare_v2 ( & format ! ( "DELETE FROM {} WHERE id = ?" , quoted) )
@@ -119,7 +119,7 @@ GROUP BY b.row_type, b.row_id",
119119 insert_statement. exec ( ) ?;
120120 }
121121 } else {
122- if buckets == "[]" {
122+ if buckets == 0 {
123123 // DELETE
124124 // language=SQLite
125125 let delete_statement = db
0 commit comments