-
Notifications
You must be signed in to change notification settings - Fork 111
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
Fluent extension causes Errors with MySQL version >= 5.7.5 #257
Comments
This is an error I've seen in recent months, and as it's a serious blocker to upgrade I'm going to raise this to critical. I'm not sure how difficult this will be to resolve... it may be necessary to remove "distinct" for certain queries (which is something that framework should NOT be doing in the first place, but that's another story). |
any updates on this? I have an upcoming project in 6 languages for which i'd like to use this module. |
Are you able to use mysql 5.6 for your project? Otherwise you can turn off |
last project i had trouble with this, so i asked my hosting partner to set up 5.6 which solved the issue, but i can imagine that this is not the case with every hoster. |
Small update on this: Turning off This means, the module should be considered incompatible with MySQL 5.7+ |
Just been discussing this on Slack, so adding another workaround that worked for me on an SS3 project a while back: $pages = SiteTree::get()->filter(array(
'ParentID' => $this->owner->ID
));
// Jumping through hoops to sort by Title in current locale...
$pages = $pages->alterDataQuery(function (DataQuery $dataQuery) {
$field = 'Title';
$alias = "{$field}_Sort";
$expression = $this->getSortExpressionForField($field, $dataQuery);
// Hack - DataQuery::selectField() is protected in SilverStripe 3
// $filtersQuery->selectField($selectSQL, $alias);
$reflectionMethod = new ReflectionMethod($dataQuery, 'selectField');
$reflectionMethod->setAccessible(true);
$reflectionMethod->invoke($dataQuery, $expression, $alias);
$dataQuery->sort($alias, 'ASC');
});
return $pages; |
It worked for us: https://github.com/sunnysideup/silverstripe-mysql-5-7-fix (see _config.php file) |
I've made a composer-patch module to fix this with 3.x Just discovered https://github.com/SpliffSplendor/silverstripe-mysqlfixer - this should do the same as lerni/silverstripe3-mysql57-fluent but per Injector - not patching. |
I would accept https://github.com/sunnysideup/silverstripe-mysql-5-7-fix/blob/master/_config.php as a PR to core fluent 3.x branch. |
@tractorcow Fluent 3.x requires SS ~3.2 but AFAIK the "config-fix" you're suggesting doesn't work with SS 3.x. Probable adding a note to https://github.com/tractorcow/silverstripe-fluent/blob/3.8/readme.md#requirements link: MySQL <5.7.5 cause of changed ANSI mode https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-combo |
Sorry, my mistake (I should read better!). The ss3 patch is a patch to core, not to _config.php. The ss4 patch only can be done via _config.php. In that case we could add the _config.php fix to the current fluent version. Regarding ss3 maybe we just recommend your patch for mysql 5.7 instead. |
@tractorcow Is this still an issue with SS/Fluent 4 after the merge of 252e489 ? |
It may still be an issue for some queries. I'm not 100% convinced it's gone. |
Just wanted to leave a note, that with v4.3.x and Fluent 4 I am still getting this issue. Was able to work around with https://github.com/sunnysideup/silverstripe-mysql-5-7-fix/blob/master/_config.php Example setup - SS4.3x, Elemental, Fluent 4 -
|
I'm experiencing this issue with Silverstripr 4.5. Is there an easy fix? |
@andreaslindahl, check out @sunnysideup workaround above - basically you can add the following to your _config.php in the root of your app folder.
|
@obj63mc Excellent, thanks! |
Is the latest Silverstripe and Fluent compatible with mysql 5.7 or do i still have to add the fix that @obj63mc suggests? I have 3 older SS3 websites on a hoster that has upgraded mysql to 5.7 so i probable have to upgrade the sites to SS4 and the latest fluent. But since this issue is still open.... |
@guyvanbael - I recently saw this in asset-admin on a live environment with fluent 4.4.5 & SS 4.5.x. But it just happened on this particular server for some reason even though other environments also use latest MySQL. |
Maybe we should add @obj63mc 's fix with a config flag (E.g. fluent_mysql_compatibility or something). |
Let's just get it in #617 |
Same PR but for 4.4 branch #618 |
Maybe I'll find some more time to fix the "make sure sorted columns" are included in the queried columns... |
I'm stuck on this one, the sql_mode trick doesn't work. Hmm it's also reported here: Looking at my SQL it seems to be inserting an empty clause into the query, perhaps that is the real culprit?
|
It looks like this line sometimes generates an empty value:
The empty value in |
The problem arises when the
FluentExtension
usesCOALESCE
on colums that should be sorted.Say you have a translatable DataObject
Article
, with aTitle
field and you want to sort byTitle
. It works in MySQL 5.6, but generates the following error on MySQL 5.7.13:I've looked around for the same issue and it seems to be caused by the following default setting: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_only_full_group_by
Multiple sources state, that it can be fixed by setting
sql-mode
to a custom value that doesn't includeONLY_FULL_GROUP_BY
, but I was unable to make it work locally. I'm assuming that a lot of people don't have full control over their mysql-server settings (depending on hosting-provider), so I guess this would be better fixed in code?The only workaround so far seems to be to disable the coalescing of fields, by setting the sortable field to be nullable. Eg.
The text was updated successfully, but these errors were encountered: