@@ -178,9 +178,9 @@ export class MongoSyncBucketStorage
178178 async resolveTable ( options : storage . ResolveTableOptions ) : Promise < storage . ResolveTableResult > {
179179 const { group_id, connection_id, connection_tag, entity_descriptor } = options ;
180180
181- const { schema, name : table , objectId, replicationColumns } = entity_descriptor ;
181+ const { schema, name, objectId, replicaIdColumns } = entity_descriptor ;
182182
183- const columns = replicationColumns . map ( ( column ) => ( {
183+ const normalizedReplicaIdColumns = replicaIdColumns . map ( ( column ) => ( {
184184 name : column . name ,
185185 type : column . type ,
186186 type_oid : column . typeId
@@ -192,8 +192,8 @@ export class MongoSyncBucketStorage
192192 group_id : group_id ,
193193 connection_id : connection_id ,
194194 schema_name : schema ,
195- table_name : table ,
196- replica_id_columns2 : columns
195+ table_name : name ,
196+ replica_id_columns2 : normalizedReplicaIdColumns
197197 } ;
198198 if ( objectId != null ) {
199199 filter . relation_id = objectId ;
@@ -206,24 +206,24 @@ export class MongoSyncBucketStorage
206206 connection_id : connection_id ,
207207 relation_id : objectId ,
208208 schema_name : schema ,
209- table_name : table ,
209+ table_name : name ,
210210 replica_id_columns : null ,
211- replica_id_columns2 : columns ,
211+ replica_id_columns2 : normalizedReplicaIdColumns ,
212212 snapshot_done : false ,
213213 snapshot_status : undefined
214214 } ;
215215
216216 await col . insertOne ( doc , { session } ) ;
217217 }
218- const sourceTable = new storage . SourceTable (
219- doc . _id ,
220- connection_tag ,
221- objectId ,
222- schema ,
223- table ,
224- replicationColumns ,
225- doc . snapshot_done ?? true
226- ) ;
218+ const sourceTable = new storage . SourceTable ( {
219+ id : doc . _id ,
220+ connectionTag : connection_tag ,
221+ objectId : objectId ,
222+ schema : schema ,
223+ name : name ,
224+ replicaIdColumns : replicaIdColumns ,
225+ snapshotComplete : doc . snapshot_done ?? true
226+ } ) ;
227227 sourceTable . syncEvent = options . sync_rules . tableTriggersEvent ( sourceTable ) ;
228228 sourceTable . syncData = options . sync_rules . tableSyncsData ( sourceTable ) ;
229229 sourceTable . syncParameters = options . sync_rules . tableSyncsParameters ( sourceTable ) ;
@@ -238,7 +238,7 @@ export class MongoSyncBucketStorage
238238
239239 let dropTables : storage . SourceTable [ ] = [ ] ;
240240 // Detect tables that are either renamed, or have different replica_id_columns
241- let truncateFilter = [ { schema_name : schema , table_name : table } ] as any [ ] ;
241+ let truncateFilter = [ { schema_name : schema , table_name : name } ] as any [ ] ;
242242 if ( objectId != null ) {
243243 // Only detect renames if the source uses relation ids.
244244 truncateFilter . push ( { relation_id : objectId } ) ;
@@ -256,15 +256,16 @@ export class MongoSyncBucketStorage
256256 . toArray ( ) ;
257257 dropTables = truncate . map (
258258 ( doc ) =>
259- new storage . SourceTable (
260- doc . _id ,
261- connection_tag ,
262- doc . relation_id ,
263- doc . schema_name ,
264- doc . table_name ,
265- doc . replica_id_columns2 ?. map ( ( c ) => ( { name : c . name , typeOid : c . type_oid , type : c . type } ) ) ?? [ ] ,
266- doc . snapshot_done ?? true
267- )
259+ new storage . SourceTable ( {
260+ id : doc . _id ,
261+ connectionTag : connection_tag ,
262+ objectId : doc . relation_id ,
263+ schema : doc . schema_name ,
264+ name : doc . table_name ,
265+ replicaIdColumns :
266+ doc . replica_id_columns2 ?. map ( ( c ) => ( { name : c . name , typeOid : c . type_oid , type : c . type } ) ) ?? [ ] ,
267+ snapshotComplete : doc . snapshot_done ?? true
268+ } )
268269 ) ;
269270
270271 result = {
@@ -620,7 +621,6 @@ export class MongoSyncBucketStorage
620621 `${ this . slot_name } Cleared batch of data in ${ lib_mongo . db . MONGO_CLEAR_OPERATION_TIMEOUT_MS } ms, continuing...`
621622 ) ;
622623 await timers . setTimeout ( lib_mongo . db . MONGO_CLEAR_OPERATION_TIMEOUT_MS / 5 ) ;
623- continue ;
624624 } else {
625625 throw e ;
626626 }
0 commit comments