wilr / silverstripe-algolia

Handles indexing Silverstripe Pages into Algolia and providing results
BSD 3-Clause "New" or "Revised" License
13 stars 16 forks source link

Not updating elemental data objects fields #45

Closed kartikpatel95 closed 2 years ago

kartikpatel95 commented 2 years ago

Elemental blocks which do not contain any extra $db properties other than the extend parents (BaseElement) element do not update AlgoliaUUID or AlgoliaIndexed DB records when running AlgoliaReindexAllJob. This is causing duplicate records in algolia when re-running AlgoliaReindexAllJob.

It cannot find record the record in the DB to update as it is on the parent table Element not the class table therefore, sprintf('UPDATE %s SET %s WHERE ID = %s', $table, $set, $this->owner->ID) is not updating anything

wilr commented 2 years ago

@kartikpatel95 The logic now checks for the correct table for this field (https://github.com/wilr/silverstripe-algolia/blob/main/src/Extensions/AlgoliaObjectExtension.php#L165). The biggest issue would be if you have that field defined on multiple tables - but in that case just manually remove the duplicate column.