@@ -242,6 +242,15 @@ protected function buildStatement($event, $changelog)
242
242
);
243
243
}
244
244
245
+ /**
246
+ * @param string $prefix
247
+ * @return string
248
+ */
249
+ public function getEntityColumn (string $ prefix ): string
250
+ {
251
+ return $ prefix . $ this ->connection ->quoteIdentifier ($ this ->getColumnName ());
252
+ }
253
+
245
254
/**
246
255
* Prepare column names and column values for trigger body
247
256
*
@@ -256,19 +265,26 @@ public function prepareTriggerBody(ChangelogInterface $changelog, string $eventT
256
265
$ this ->connection ->describeTable ($ this ->getTableName ()),
257
266
'COLUMN_NAME '
258
267
);
268
+ $ describedClColumns = array_column (
269
+ $ this ->connection ->describeTable ($ changelog ->getName ()),
270
+ 'COLUMN_NAME '
271
+ );
259
272
$ viewConfig = $ this ->mviewConfig ->getView ($ this ->getView ()->getId ());
260
273
$ columnNames = [$ this ->connection ->quoteIdentifier ($ changelog ->getColumnName ())];
261
- $ columnValues = [$ this ->connection -> quoteIdentifier ( $ this -> getColumnName () )];
274
+ $ columnValues = [$ this ->getEntityColumn ( $ prefix )];
262
275
//If we need to add attributes
263
276
if ($ viewConfig [ChangelogInterface::ATTRIBUTE_SCOPE_SUPPORT ] &&
264
- array_search (Changelog::ATTRIBUTE_COLUMN , $ describedSubscribedColumns )
277
+ array_search (Changelog::ATTRIBUTE_COLUMN , $ describedSubscribedColumns ) &&
278
+ array_search (Changelog::ATTRIBUTE_COLUMN , $ describedClColumns )
279
+
265
280
) {
266
281
$ columnValues [] = $ prefix . $ this ->connection ->quoteIdentifier (Changelog::ATTRIBUTE_COLUMN );
267
282
$ columnNames [] = $ this ->connection ->quoteIdentifier (Changelog::ATTRIBUTE_COLUMN );
268
283
}
269
284
//If we need to add stores
270
285
if ($ viewConfig [ChangelogInterface::STORE_SCOPE_SUPPORT ] &&
271
- array_search (Changelog::STORE_COLUMN , $ describedSubscribedColumns )
286
+ array_search (Changelog::STORE_COLUMN , $ describedSubscribedColumns ) &&
287
+ array_search (Changelog::STORE_COLUMN , $ describedClColumns )
272
288
) {
273
289
$ columnValues [] = $ prefix . $ this ->connection ->quoteIdentifier (Changelog::STORE_COLUMN );
274
290
$ columnNames [] = $ this ->connection ->quoteIdentifier (Changelog::STORE_COLUMN );
0 commit comments