Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conference search error #494

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

andrewmile
Copy link
Collaborator

@andrewmile andrewmile commented Dec 8, 2023

This PR fixes an error that occurring when the Laravel\Scout\Jobs\MakeSearchable job is queued for a conference. These jobs are failing with a MaxAttemptsExceededException being thrown. These jobs are inserted in the failed_jobs table with the correct conference ID but the underlying query is recorded in Bugsnag as follows:

select * from `conferences` where `conferences`.`id` in (0)

This Scout issue led me to the Laravel\Scout\Searchable::queryScoutModelsByIds method, which determine's the model's key via the Model::getKeyType method. When the key type is int, which is the Eloquent default, the query is built with whereIntegerInRaw, which cast's the key as an int.

Since the Conference model uses a UUID primary key, the queryScoutModelsByIds method was casting the UUID value as an int, which resulted in the SQL query above.

Adding protected $keyType = 'string'; to the App\Models\UuidBase class results in the queryScoutModelsByIds method using a whereIn query instead of the whereIntegerInRaw, which fixes this issue.

This fix is tested by using collection as the SCOUT_DRIVER for PHPUnit since the database driver doesn't call the queryScoutModelsByIds method.

@andrewmile andrewmile self-assigned this Dec 8, 2023
@andrewmile andrewmile merged commit f30753a into develop Dec 8, 2023
3 checks passed
@andrewmile andrewmile deleted the ajm/fix-queued-conference-search-errors branch December 8, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant