@@ -23,7 +23,7 @@ impl InferredTableStructure {
2323 pub fn read_from_database (
2424 table_name : & str ,
2525 db : impl Connection ,
26- ignored_local_columns : & ColumnFilter ,
26+ synced_columns : & Option < ColumnFilter > ,
2727 ) -> Result < Option < Self > , PowerSyncError > {
2828 let stmt = db. prepare_v2 ( "select name from pragma_table_info(?)" ) ?;
2929 stmt. bind_text ( 1 , table_name, Destructor :: STATIC ) ?;
@@ -35,7 +35,11 @@ impl InferredTableStructure {
3535 let name = stmt. column_text ( 0 ) ?;
3636 if name == "id" {
3737 has_id_column = true ;
38- } else if !ignored_local_columns. matches ( name) {
38+ } else if let Some ( filter) = synced_columns
39+ && !filter. matches ( name)
40+ {
41+ // This column isn't part of the synced columns, skip.
42+ } else {
3943 columns. push ( name. to_string ( ) ) ;
4044 }
4145 }
@@ -64,9 +68,9 @@ pub fn generate_raw_table_trigger(
6468 return Err ( PowerSyncError :: argument_error ( "Table has no local name" ) ) ;
6569 } ;
6670
67- let local_only_columns = & table. schema . local_only_columns ;
71+ let synced_columns = & table. schema . synced_columns ;
6872 let Some ( resolved_table) =
69- InferredTableStructure :: read_from_database ( local_table_name, db, local_only_columns ) ?
73+ InferredTableStructure :: read_from_database ( local_table_name, db, synced_columns ) ?
7074 else {
7175 return Err ( PowerSyncError :: argument_error ( format ! (
7276 "Could not find {} in local schema" ,
@@ -85,10 +89,10 @@ pub fn generate_raw_table_trigger(
8589 // Skip the trigger for writes during sync_local, these aren't crud writes.
8690 buffer. push_str ( "WHEN NOT powersync_in_sync_operation()" ) ;
8791
88- if write == WriteType :: Update && !local_only_columns . as_ref ( ) . is_empty ( ) {
92+ if write == WriteType :: Update && synced_columns . is_some ( ) {
8993 buffer. push_str ( " AND\n (" ) ;
90- // If we have local-only columns, we want to add additional WHEN clauses to ensure the
91- // trigger runs for updates on synced columns.
94+ // If we have a filter for synced columns (instead of syncing all of them), we want to add
95+ // additional WHEN clauses to enesure the trigger runs for updates on those columns only .
9296 for ( i, name) in as_schema_table. column_names ( ) . enumerate ( ) {
9397 if i != 0 {
9498 buffer. push_str ( " OR " ) ;
0 commit comments