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

Entry query "DESCLIMIT" invalid SQL #611

Closed
wolispace opened this issue Jan 22, 2024 · 3 comments
Closed

Entry query "DESCLIMIT" invalid SQL #611

wolispace opened this issue Jan 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wolispace
Copy link

On the 'Entry Queries' ie this page:
https://putyourlightson.com/articles/introducing-blitz-diagnostics#tracked-element-queries

When we copy the SQL and paste it, we see a sort order has been added to the query without wrapping it with spaces.. so we end up with in invalid SQL: "DESCLIMIT"

SELECT elements.idASelementIdFROM (SELECT elements.idASelementsId, elements_sites.idASelementsSitesId, content.idAScontentIdFROM elements elementsINNER JOIN entries entriesONentries.id=elements.idINNER JOIN elements_sites elements_sitesONelements_sites.elementId=elements.idINNER JOIN content content ON (content.elementId=elements.id) AND (content.siteId=elements_sites.siteId)LEFT JOIN structureelements structureelements ON (structureelements.elementId=elements.id) AND (structureelements.structureId=13)WHERE (entries.sectionId=4) AND (elements_sites.siteId=1) AND (elements.archived=FALSE) AND (elements.dateDeleted IS NULL) AND (elements.draftId IS NULL) AND (elements.revisionIdIS NULL)ORDER BYelements.dateUpdatedDESCLIMIT 1)subqueryINNER JOIN elements elementsONelements.id=subquery.elementsIdINNER JOIN elements_sites elements_sitesONelements_sites.id=subquery.elementsSitesIdINNER JOIN entries entriesONentries.id=subquery.elementsIdINNER JOIN content contentONcontent.id=subquery.contentIdLEFT JOIN structureelements structureelements ON (structureelements.elementId=subquery.elementsId) AND (structureelements.structureId=13)ORDER BY elements.dateUpdated DESC;

Notice there is no space before 'ORDER BY' so its possibly this being added without wrapping in spaces:

"ORDER BY elements.dateUpdated DESC"

@wolispace wolispace added the bug Something isn't working label Jan 22, 2024
@bencroker
Copy link
Collaborator

It sounds like perhaps line breaks need to be replaced with spaces before the SQL string is output. Thanks for reporting this, I'll work on a fix for the next release.

@bencroker
Copy link
Collaborator

Fixed in 2d8214c for the next release.

@bencroker
Copy link
Collaborator

Released in 4.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants