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

Remove unnecessary SQL queries #1454

Open
mindaugasvcs opened this issue Nov 18, 2023 · 1 comment
Open

Remove unnecessary SQL queries #1454

mindaugasvcs opened this issue Nov 18, 2023 · 1 comment

Comments

@mindaugasvcs
Copy link

mindaugasvcs commented Nov 18, 2023

$tag = $tags->findOneBy(['name' => $request->query->get('tag')]);

Hi,
I think a reference application should not promote unnecessary SQL queries. You fetch a tag object from DB then execute another SQL call, why not just passing a tag as a string to the PostRepository instead? Can I offer PR to fix this line to use just one SQL call?

@GromNaN
Copy link
Member

GromNaN commented Nov 20, 2023

This query return null if the tag is not found. So the subsequent query has not filter on the tag.
This is not an ideal behavior for users. It would be better to return a 404 when no article are found with the given tag (that's what news websites does of SEO).

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