Skip to content

Laravel 11.19 breaks this package #16

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

Closed
vesper8 opened this issue Sep 25, 2024 · 3 comments
Closed

Laravel 11.19 breaks this package #16

vesper8 opened this issue Sep 25, 2024 · 3 comments

Comments

@vesper8
Copy link

vesper8 commented Sep 25, 2024

In Laravel 11.19 (https://github.com/laravel/framework/releases/tag/v11.19.0) this PR was added:

laravel/framework#52227

This causes this query:

        $snapshot = $this->snapshot
            ->newQuery()
            ->whereMorphedTo($this->snapshot->subject(), $this->model->getMorphClass())
            ->latest()
            ->first();

To result in this SQL:


select * from `model_snapshots` where `related_table`.`subject_type` = ? order by `created_at` desc

Instead of


select * from `model_snapshots` where `subject_type` = ? order by `created_at` desc

Basically it looks for subject_type on the related_table instead of on the model_snapshots table.

I'm not entirely sure why this is happening.. perhaps the whereMorphedTo method is the wrong method to use here?

Any chance you could fix this query so that it explicitly looks for subject_type to avoid this issue?

Something like this perhaps


$snapshot = $this->snapshot
    ->newQuery()
    ->where(function ($query) {
        $query->where('subject_type', $this->model->getMorphClass());
    })
    ->latest()
    ->first();

Many thanks!

@EriBloo
Copy link
Owner

EriBloo commented Sep 25, 2024

Hi.
Thanks for info. I will fix this soon.

Cheers!

@EriBloo
Copy link
Owner

EriBloo commented Sep 30, 2024

This should be fixed now ;)

@EriBloo EriBloo closed this as completed Sep 30, 2024
@vesper8
Copy link
Author

vesper8 commented Oct 1, 2024

Yay awesome thank you!

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

No branches or pull requests

2 participants