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

[10.x] Get the key name through getScoutKeyName() on the Database engine #843

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

antonioribeiro
Copy link
Contributor

I'm not sure why the database engine is the only still using getKeyName(), but it should be using getScoutKeyName() as all the others. I just found this while trying to set a custom ID for my searches other than the one I'm using for normal usage of the searchable model.

While trying to join a table:

Post::search($search)
    ->query(function ($query) {
        ...

        $query->join('twill_blocks', 'posts.id', '=', 'twill_blocks.blockable_id');
    })
    ->get();

Scout was raising a Column 'id' in order clause is ambiguous caused by an unqualified order by id that was not possible to customize as the only way would be by overloading getKeyName() and that would break how things work for my Post model out of the search context.

@antonioribeiro antonioribeiro changed the title Get the key name through getScoutKeyName() Get the key name through getScoutKeyName() on the Database engine Jul 1, 2024
@driesvints driesvints changed the title Get the key name through getScoutKeyName() on the Database engine [10.x] Get the key name through getScoutKeyName() on the Database engine Jul 2, 2024
@taylorotwell taylorotwell merged commit ab3c691 into laravel:10.x Jul 2, 2024
15 checks passed
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.

2 participants