diff -u b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php --- b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -247,7 +247,6 @@ $high_water_field = $this->getHighWaterField(); $conditions->condition($high_water_field, $high_water, '>'); $this->query->orderBy($high_water_field); - $condition_added = TRUE; } if ($condition_added) { $this->query->condition($conditions); @@ -275,6 +274,7 @@ $high_water_field = $this->getHighWaterField(); $conditions->condition($high_water_field, $high_water, '>'); $this->query->orderBy($high_water_field); + $condition_added = TRUE; } if ($condition_added) { $this->query->condition($conditions); diff -u b/core/modules/migrate/tests/src/Kernel/HighWaterNotJoinableTest.php b/core/modules/migrate/tests/src/Kernel/HighWaterNotJoinableTest.php --- b/core/modules/migrate/tests/src/Kernel/HighWaterNotJoinableTest.php +++ b/core/modules/migrate/tests/src/Kernel/HighWaterNotJoinableTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\migrate\Kernel; /** - * Tests the Drupal 6 comment source w/ high water handling. + * Tests the high water handling. * * @covers \Drupal\migrate_sql_test\Plugin\migrate\source\HighWaterTest * @group migrate only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php +++ b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php @@ -137,6 +137,64 @@ public function testHighWater() { } /** + * Tests high water property of SqlBase when rows marked for update. + */ + public function testHighWaterUpdate() { + // Assert all of the nodes have been imported. + $this->assertNodeExists('Item 1'); + $this->assertNodeExists('Item 2'); + $this->assertNodeExists('Item 3'); + + // Update Item 1 setting its high_water_property to value that is below + // current high water mark. + $this->sourceDatabase->update('high_water_node') + ->fields([ + 'title' => 'Item 1 updated', + 'changed' => 2, + ]) + ->condition('title', 'Item 1') + ->execute(); + + // Update Item 2 setting its high_water_property to value equal to + // current high water mark. + $this->sourceDatabase->update('high_water_node') + ->fields([ + 'title' => 'Item 2 updated', + 'changed' => 3, + ]) + ->condition('title', 'Item 2') + ->execute(); + + // Update Item 3 setting its high_water_property to value that is above + // current high water mark. + $this->sourceDatabase->update('high_water_node') + ->fields([ + 'title' => 'Item 3 updated', + 'changed' => 4, + ]) + ->condition('title', 'Item 3') + ->execute(); + + // Set all rows as needing an update. + $id_map = $this->getMigration('high_water_test')->getIdMap(); + $id_map->prepareUpdate(); + + $this->executeMigration('high_water_test'); + + // Item with lower highwater should be updated. + $this->assertNodeExists('Item 1 updated'); + $this->assertNodeDoesNotExist('Item 1'); + + // Item with equal highwater should be updated. + $this->assertNodeExists('Item 2 updated'); + $this->assertNodeDoesNotExist('Item 2'); + + // Item with greater highwater should be updated. + $this->assertNodeExists('Item 3 updated'); + $this->assertNodeDoesNotExist('Item 3'); + } + + /** * Assert that node with given title exists. * * @param string $title