Skip to content

Commit 0028ce6

Browse files
author
Anton Evers
committed
Prevent unit tests from failing
1 parent 433c9c3 commit 0028ce6

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,12 @@ protected function buildStatement($event, $changelog)
186186
$skipColumns = ['updated_at'];
187187
$describe = $this->connection->describeTable($this->getTableName());
188188
$columns = [];
189-
foreach ($describe as $column) {
190-
if (!in_array($column['COLUMN_NAME'], $skipColumns)) {
191-
$columns[] = sprintf('NEW.%1$s <> OLD.%1$s',
192-
$this->connection->quoteIdentifier($column['COLUMN_NAME']));
189+
if (is_array($describe)) {
190+
foreach ($describe as $column) {
191+
if (!in_array($column['COLUMN_NAME'], $skipColumns)) {
192+
$columns[] = sprintf('NEW.%1$s != OLD.%1$s',
193+
$this->connection->quoteIdentifier($column['COLUMN_NAME']));
194+
}
193195
}
194196
}
195197

@@ -202,9 +204,17 @@ protected function buildStatement($event, $changelog)
202204
$this->connection->quoteIdentifier($this->getColumnName())
203205
);
204206
case Trigger::EVENT_UPDATE:
207+
if ($columns) {
208+
return sprintf(
209+
"IF (%s) THEN INSERT IGNORE INTO %s (%s) VALUES (NEW.%s); END IF;",
210+
implode(' OR ', $columns),
211+
$this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
212+
$this->connection->quoteIdentifier($changelog->getColumnName()),
213+
$this->connection->quoteIdentifier($this->getColumnName())
214+
);
215+
}
205216
return sprintf(
206-
"IF (%s) THEN INSERT IGNORE INTO %s (%s) VALUES (NEW.%s); END IF;",
207-
implode(' OR ', $columns),
217+
"INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);",
208218
$this->connection->quoteIdentifier($this->resource->getTableName($changelog->getName())),
209219
$this->connection->quoteIdentifier($changelog->getColumnName()),
210220
$this->connection->quoteIdentifier($this->getColumnName())

0 commit comments

Comments
 (0)