-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Setcontent with order by causes SQL exception in 4.1 #1971
Comments
Removing the |
I suspect something in this pull request has introduced this. For example, this comment references casting b2_.value to TEXT for non-MySQL databases (although my driver in .env is using mysql: |
Hmm, it seems to be working fine here, on my Mysql 5.7 setup. I can do this:
And the result is: SELECT content FROM Bolt\Entity\Content content LEFT JOIN content.fields fields_order_1 LEFT JOIN fields_order_1.translations translations_order_1 WHERE content.contentType = :ct0 AND content.status = :status_1 AND fields_order_1.name = :order_1 ORDER BY lower(CAST(translations_order_1.value as BLOB)) DESC
Where are you removing this? From It seems like
Alternatively, could you check to see that happens if you order on a text field?
|
The culprit could be very well the A difference between MySQL and MariaDB is that MariaDB uses LONGTEXT, maybe a good direction to start investigating. I wonder what your |
Hi @bobdenotter ,
This query looks different to mine - in place of Might this be because I wasn't using
No, I've not touched any code. I had copied the query and ran it directly against MariaDB in PhpMyAdmin, replacing the ?s with the actual parameter values. I observed the same error from MariaDB. When I removed the
The same - I still get the LOWER and CAST to a TEXT field. It seems as though it's the datatype MariaDB doesn't like. CASTing to CHAR works, but to a TEXT or BLOB results in the same error. Working:
Not working:
Do you know which package this file is in? I'm using a standard Composer install of Bolt. |
I did see that in your code and thought the CAST shouldn’t be there Thinking more about this (while I’m not at my computer!) I wonder if Doctrine is sniffing the DB version string and switching out the driver name as mariadb instead of mysql? I’m assuming there are other syntax differences that Doctrine needs to handle between the two. As soon as I can get back to my computer I’ll find the file and check what the property yields. |
@Wieter, the code in I believe it is this commit which was introduced with the PostgreSQL functionality - it isn't checking for MySQL and is always including the CAST - compared to the I'm going to submit a PR now, hope this is OK @bobdenotter, it's my first contribution to Bolt 😄 |
A short summary of the findings in PR #1977 (which can be closed, as a different fix should be implemented): The cause of this problem is the following: Using composer install an More is missing from the doctrine config (
Using a git installation of bolt/core:master, this problem is not present as a correct |
@bobdenotter Composer install get its |
We can't directly link to it, because once it's been "composer create project"-ed, it's set in stone. There's two things we can do:
Up until now, it's been a manual task to ensure changes in |
I can confirm this bug (it's problematic because sites in production are affected).
|
We're updating The fix is detailed in this reply, above: #1971 (comment) |
Thanks @bobdenotter Is there a way to stop Composer pulling new 4.x releases automatically? I.e. I just did a I would happily expect 4.0.1 -> 4.0.2 to be pulled in automatically as this shouldn't require any changes, but if I was directed to an "upgrade guide" to go from 4.0.x -> 4.1.x, the additional requirements could be documented in that. |
Maybe on the long run these things that are so essential to the proper functioning of bolt/core should indeed be migrated into |
Yes, by setting it to But, ideally we won't be breaking anything in minor versions, because we're trying to stick to SemVer. We're still getting the hang of that, after the big Four Point Oh release. :-) @Wieter :
If we can come up with a reliable way to do so, that'd be nice.. Thinking out loud: It should be able to handle duplicates and overrides (which will happen if people create-project from newer versions. 🤔 💭 |
Since upgrading to 4.1, a "setcontent" clause with an order by is causing a SQL exception.
Details
Reproduction
Bug summary
Including an orderby clause in setcontent is throwing a SQL exception in Bolt 4.1.0 (with latest dependencies installed using composer update.)
Specifics
On my home page template, I am using "setcontent" to render the last 6 items of content type "reviews" in descending order based on the "date" field.
My content type:
The twig tag:
This worked correctly in 4.0.1, but is throwing the following exception in 4.1.0:
The database is hosted on MariaDB 10.5.5, PHP 7.4.10.
Steps to reproduce
Expected result
The tag would work, and something like
{{ reviews|length }}
would show the number of review items added.Actual result
Exception as described above.
Switching the order by tag to ascending results in the same exception.
Removing the order by tag works but obviously the content is not ordered.
The text was updated successfully, but these errors were encountered: