Skip to content

Commit 8c754b2

Browse files
Allow ignored columns at subscription level to be enabled/disabled
1 parent 0417ffc commit 8c754b2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,15 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
333333
{
334334
$tableName = 'cataloginventory_stock_item';
335335
$ignoredColumnName = 'low_stock_date';
336+
$notIgnoredColumnName = 'backorders';
336337
$viewId = 'cataloginventory_stock';
337338
$ignoredData = [
338-
$viewId => [$tableName => [$ignoredColumnName]]
339+
$viewId => [
340+
$tableName => [
341+
$ignoredColumnName => true,
342+
$notIgnoredColumnName => false
343+
]
344+
]
339345
];
340346

341347
$this->connectionMock->expects($this->once())
@@ -349,6 +355,7 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
349355
'stock_id' => ['COLUMN_NAME' => 'stock_id'],
350356
'qty' => ['COLUMN_NAME' => 'qty'],
351357
$ignoredColumnName => ['COLUMN_NAME' => $ignoredColumnName],
358+
$notIgnoredColumnName => ['COLUMN_NAME' => $notIgnoredColumnName]
352359
]);
353360

354361
$otherChangelogMock = $this->getMockForAbstractClass(ChangelogInterface::class);
@@ -372,5 +379,6 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
372379
$statement = $method->invoke($model, Trigger::EVENT_UPDATE, $otherChangelogMock);
373380

374381
$this->assertStringNotContainsString($ignoredColumnName, $statement);
382+
$this->assertStringContainsString($notIgnoredColumnName, $statement);
375383
}
376384
}

lib/internal/Magento/Framework/Mview/View/Subscription.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,12 @@ protected function buildStatement($event, $changelog)
216216
$describe = $this->connection->describeTable($tableName)
217217
) {
218218
$columnNames = array_column($describe, 'COLUMN_NAME');
219+
$ignoredColumnsBySubscription = array_filter(
220+
$this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? []
221+
);
219222
$ignoredColumns = array_merge(
220223
$this->ignoredUpdateColumns,
221-
$this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? []
224+
array_keys($ignoredColumnsBySubscription)
222225
);
223226
$columnNames = array_diff($columnNames, $ignoredColumns);
224227
if ($columnNames) {

0 commit comments

Comments
 (0)