Skip to content

Commit e8d102d

Browse files
committed
Delete stream subscriptions on clear
1 parent 6d6863f commit e8d102d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/core/src/view_admin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ DELETE FROM ps_untyped;
162162
DELETE FROM ps_updated_rows;
163163
DELETE FROM ps_kv WHERE key != 'client_id';
164164
DELETE FROM ps_sync_state;
165+
DELETE FROM ps_stream_subscriptions;
165166
",
166167
)?;
167168

dart/test/sync_stream_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,4 +648,18 @@ void main() {
648648
}
649649
]));
650650
});
651+
652+
syncTest('clearing database clears subscriptions', (_) {
653+
control(
654+
'subscriptions',
655+
json.encode({
656+
'subscribe': {
657+
'stream': {'name': 'a'},
658+
}
659+
}),
660+
);
661+
expect(db.select('select * from ps_stream_subscriptions'), isNotEmpty);
662+
db.execute('select powersync_clear(0);');
663+
expect(db.select('select * from ps_stream_subscriptions'), isEmpty);
664+
});
651665
}

0 commit comments

Comments
 (0)