[9.x] Remove custom unserialize from RemoveFromSearch #479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The custom unserialization process in the
RemoveFromSearch
job does not take a customized scout key into account correctly.Given a model with an overriden key like below that relies on other data on the model, the engines won't be able to process the models since they only have their primary key to work with.
In the case of the MeiliSearch engine, it will queue a request to delete a model with the key of
null
. This request continues on to MeiliSearch proper and it processes the request just fine, resulting in nothing being deleted. I'm not sure what the result would be on any other engine, but I would expect it to be similar.The original PR that added this functionality added a test
test_models_are_deserialized_without_the_database
. In the process of creating this PR, I tried to think of ways to preserve that functionality by possibly customizing the serialization as well, or altering what the constructor does. I failed to come up with a clean and simple way to preserve that functionality. Every attempt I tried felt brittle.Instead, I feel that this job being able to deserialize a model without the database is beyond the scope of what this package is aiming to provide, especially since the same feature is not available on the
MakeSearchable
job. If this avoiding the database for deserialization is required by an application, a custom version of the job could be used instead thanks to #476.