Skip to content

Commit e7bcd13

Browse files
committed
Record edit conflict when UPDATE is rebased on top of DELETE
1 parent 0a94b5b commit e7bcd13

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

geodiff/src/geodiffrebase.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,20 @@ bool _handle_update( const ChangesetEntry &entry, const RebaseMapping &mapping,
471471
{
472472
int newPk = mapping.getNewPkey( entry.table->name, pk );
473473
if ( newPk == RebaseMapping::INVALID_FID )
474+
{
475+
// our UPDATE conflicts with their DELETE: record as conflict, delete wins
476+
ConflictFeature conflictFeature( pk, entry.table->name );
477+
for ( size_t i = 0; i < numColumns; i++ )
478+
{
479+
if ( entry.newValues[i].type() != Value::TypeUndefined )
480+
{
481+
_addConflictItem( conflictFeature, ( int ) i, entry.oldValues[i], Value(), entry.newValues[i] );
482+
}
483+
}
484+
if ( conflictFeature.isValid() )
485+
conflicts.push_back( conflictFeature );
474486
return false;
487+
}
475488
}
476489

477490
// find the previously new values (will be used as the old values in the rebased version)

geodiff/tests/test_concurrent_commits.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ TEST( ConcurrentCommitsSqlite3Test, test_delete_update )
381381
{
382382
std::cout << "geopackage concurent DELETE (base) -> (A) and UPDATE (base) -> (B)" << std::endl;
383383
std::cout << "(A) deleted the feature 2 and (B) edits the geom of feature 2" << std::endl;
384-
std::cout << "expected result: feature 2 is deleted" << std::endl;
384+
std::cout << "expected result: feature 2 is deleted, conflict recorded for the discarded update" << std::endl;
385385

386386
bool ret = _test(
387387
"base.gpkg",
@@ -392,7 +392,7 @@ TEST( ConcurrentCommitsSqlite3Test, test_delete_update )
392392
1,
393393
0,
394394
1,
395-
0
395+
1
396396
);
397397
ASSERT_TRUE( ret );
398398
}

0 commit comments

Comments
 (0)