@@ -79,6 +79,8 @@ export interface SQLWatchOptions {
79
79
/** The minimum interval between queries. */
80
80
throttleMs ?: number ;
81
81
/**
82
+ * @deprecated All tables specified in {@link tables} will be watched, including PowerSync tables with prefixes.
83
+ *
82
84
* Allows for watching any SQL table
83
85
* by not removing PowerSync table name prefixes
84
86
*/
@@ -889,7 +891,9 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
889
891
}
890
892
891
893
const resolvedOptions = options ?? { } ;
892
- const watchedTables = new Set ( resolvedOptions . tables ?? [ ] ) ;
894
+ const watchedTables = new Set < string > (
895
+ ( resolvedOptions ?. tables ?? [ ] ) . flatMap ( ( table ) => [ table , `ps_data__${ table } ` , `ps_data_local__${ table } ` ] )
896
+ ) ;
893
897
894
898
const changedTables = new Set < string > ( ) ;
895
899
const throttleMs = resolvedOptions . throttleMs ?? DEFAULT_WATCH_THROTTLE_MS ;
@@ -910,8 +914,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
910
914
const dispose = this . database . registerListener ( {
911
915
tablesUpdated : async ( update ) => {
912
916
try {
913
- const { rawTableNames } = resolvedOptions ;
914
- this . processTableUpdates ( update , rawTableNames , changedTables ) ;
917
+ this . processTableUpdates ( update , changedTables ) ;
915
918
flushTableUpdates ( ) ;
916
919
} catch ( error ) {
917
920
onError ?.( error ) ;
@@ -976,24 +979,13 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
976
979
977
980
private processTableUpdates (
978
981
updateNotification : BatchedUpdateNotification | UpdateNotification ,
979
- rawTableNames : boolean | undefined ,
980
982
changedTables : Set < string >
981
983
) : void {
982
984
const tables = isBatchedUpdateNotification ( updateNotification )
983
985
? updateNotification . tables
984
986
: [ updateNotification . table ] ;
985
987
986
- const filteredTables = rawTableNames ? tables : tables . filter ( ( t ) => ! ! t . match ( POWERSYNC_TABLE_MATCH ) ) ;
987
- if ( ! filteredTables . length ) {
988
- return ;
989
- }
990
-
991
- // Remove any PowerSync table prefixes if necessary
992
- const mappedTableNames = rawTableNames
993
- ? filteredTables
994
- : filteredTables . map ( ( t ) => t . replace ( POWERSYNC_TABLE_MATCH , '' ) ) ;
995
-
996
- for ( const table of mappedTableNames ) {
988
+ for ( const table of tables ) {
997
989
changedTables . add ( table ) ;
998
990
}
999
991
}
0 commit comments