Skip to content

Conversation

aimeos
Copy link
Contributor

@aimeos aimeos commented Mar 4, 2023

For queries to a single resource (e.g. v1/pages/1 ) for which no relations should be fetched, there's an unnecessary query executed:

select "id" from "pages" where "pages"."id" in (1)

This is because $this->queryParameters->countable() returns NULL here:
https://github.com/laravel-json-api/eloquent/blob/develop/src/QueryOne.php#L125

The patch checks for NULL values and avoids that query in this case.

Copy link
Contributor

@lindyhopchris lindyhopchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking up on this. Have suggested an improvement to your change. If you add that, then we can get this merged.

@aimeos
Copy link
Contributor Author

aimeos commented Mar 12, 2023

Thanks, replaced the code with your suggestion.

@aimeos
Copy link
Contributor Author

aimeos commented Mar 30, 2023

@lindyhopchris Can you merge the PR now?

@lindyhopchris
Copy link
Contributor

Sorry, thanks for the prompt! Yeah will merge and tag this weekend.

@lindyhopchris lindyhopchris merged commit 49a1932 into laravel-json-api:develop Apr 3, 2023
@lindyhopchris
Copy link
Contributor

Apologies this took a while. Tagged as v3.0.1. Thanks for your contribution!

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