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

Fix casting exception with orderby when using MySQL/PostgreSQL #2290

Merged
merged 1 commit into from
Jan 7, 2021

Conversation

I-Valchev
Copy link
Member

Fixes #2241

@@ -116,6 +116,8 @@ private function setOrderBy(QueryInterface $query, string $order, string $direct
// Note the `lower()` in the `addOrderBy()`. It is essential to sorting the
// results correctly. See also https://github.com/bolt/core/issues/1190
// again: lower breaks postgresql jsonb compatibility, first cast as txt
// cast as TEXT or CHAR, depending on SQL support. See Bolt\Doctrine\Query\Cast.php
// and https://github.com/bolt/core/issues/2241
$query
->getQueryBuilder()
->addOrderBy('lower(CAST(' . $translationsAlias . '.value as TEXT))', $direction);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this TEXT also be dependent on the platform, then?

Copy link
Member

Choose a reason for hiding this comment

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

(As explained by Ivo: No, it shouldn't)

@bobdenotter bobdenotter merged commit 1273a00 into 4.1 Jan 7, 2021
@bobdenotter bobdenotter deleted the bugfix/cast-exception-order-by branch January 7, 2021 13:46
@bobdenotter bobdenotter changed the title Fix casting exception withorderby when using MySQL/PostgreSQL Fix casting exception with orderby when using MySQL/PostgreSQL Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with 'orderby' in query
2 participants