@@ -69,14 +69,14 @@ WITH updated_rows AS (
69
69
SELECT b.row_type, b.row_id FROM ps_buckets AS buckets
70
70
CROSS JOIN ps_oplog AS b ON b.bucket = buckets.id
71
71
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
73
73
)
74
74
75
75
-- 3. Group the objects from different buckets together into a single one (ops).
76
76
SELECT b.row_type as type,
77
77
b.row_id as id,
78
78
r.data as data,
79
- json_group_array (r.bucket) as buckets,
79
+ count (r.bucket) as buckets,
80
80
/* max() affects which row is used for 'data' */
81
81
max(r.op_id) as op_id
82
82
-- 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",
94
94
while statement. step ( ) . into_db_result ( db) ? == ResultCode :: ROW {
95
95
let type_name = statement. column_text ( 0 ) ?;
96
96
let id = statement. column_text ( 1 ) ?;
97
- let buckets = statement. column_text ( 3 ) ?;
97
+ let buckets = statement. column_int ( 3 ) ?;
98
98
let data = statement. column_text ( 2 ) ;
99
99
100
100
let table_name = internal_table_name ( type_name) ;
101
101
102
102
if tables. contains ( & table_name) {
103
103
let quoted = quote_internal_name ( type_name, false ) ;
104
104
105
- if buckets == "[]" || buckets == "[null]" {
105
+ if buckets == 0 {
106
106
// DELETE
107
107
let delete_statement = db
108
108
. prepare_v2 ( & format ! ( "DELETE FROM {} WHERE id = ?" , quoted) )
@@ -119,7 +119,7 @@ GROUP BY b.row_type, b.row_id",
119
119
insert_statement. exec ( ) ?;
120
120
}
121
121
} else {
122
- if buckets == "[]" {
122
+ if buckets == 0 {
123
123
// DELETE
124
124
// language=SQLite
125
125
let delete_statement = db
0 commit comments