@@ -79,6 +79,8 @@ export interface SQLWatchOptions {
7979 /** The minimum interval between queries. */
8080 throttleMs ?: number ;
8181 /**
82+ * @deprecated All tables specified in {@link tables} will be watched, including PowerSync tables with prefixes.
83+ *
8284 * Allows for watching any SQL table
8385 * by not removing PowerSync table name prefixes
8486 */
@@ -889,7 +891,9 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
889891 }
890892
891893 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+ ) ;
893897
894898 const changedTables = new Set < string > ( ) ;
895899 const throttleMs = resolvedOptions . throttleMs ?? DEFAULT_WATCH_THROTTLE_MS ;
@@ -910,8 +914,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
910914 const dispose = this . database . registerListener ( {
911915 tablesUpdated : async ( update ) => {
912916 try {
913- const { rawTableNames } = resolvedOptions ;
914- this . processTableUpdates ( update , rawTableNames , changedTables ) ;
917+ this . processTableUpdates ( update , changedTables ) ;
915918 flushTableUpdates ( ) ;
916919 } catch ( error ) {
917920 onError ?.( error ) ;
@@ -976,24 +979,13 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
976979
977980 private processTableUpdates (
978981 updateNotification : BatchedUpdateNotification | UpdateNotification ,
979- rawTableNames : boolean | undefined ,
980982 changedTables : Set < string >
981983 ) : void {
982984 const tables = isBatchedUpdateNotification ( updateNotification )
983985 ? updateNotification . tables
984986 : [ updateNotification . table ] ;
985987
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 ) {
997989 changedTables . add ( table ) ;
998990 }
999991 }
0 commit comments