xpdo 2.5.3-pl not working $query->groupby() #13287

Open
andchir opened this Issue Feb 10, 2017 · 8 comments

Projects

None yet

4 participants

@andchir
andchir commented Feb 10, 2017

Summary

xpdo 2.5.3-pl not working $query->groupby().

Step to reproduce

Make query with $query->groupby() no results.

Environment

modx 2.5.1pl, xpdo 2.5.3-pl

@Mark-H
Collaborator
Mark-H commented Feb 10, 2017

MODX 2.5.1? Update immediately, you're vulnerable to some serious issues.

Also if this is the bug I think it is (hard to tell if you don't provide at the very least the query you're building) that would also be resolved in 2.5.4+.

@andchir
andchir commented Feb 10, 2017 edited

Thank you for your answer. I updated to MODX 2.5.5. But the problem with $query->groupby() is not solved.

@OptimusCrime
Contributor

@andchir Can you provide the actual code that does not work?

@andchir
andchir commented Feb 10, 2017 edited

Example:

$query = $modx->newQuery('modResource');
$query->select(array('id','parent','pagetitle'));
$query->sortby('pagetitle','asc');
$query->groupby('parent');

$collection = $modx->getCollection('modResource', $query);

var_dump( count( $collection ) );//Output: int(0)

If I remove $query->groupby('parent'); - output: int(36)

@andchir
andchir commented Feb 10, 2017 edited

Maybe this is my local MySQL settings. I have message:

SELECT list is not in GROUP BY clause and contains nonaggregated column 'modx.modResource.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

MySQL version: 5.7.17

@Jako
Collaborator
Jako commented Feb 10, 2017

You have some STRICT checks enabled in the MySQL/MariaDB configuration.

$query->select($modx->getSelectColumns('modResource','modResource','',array('id','parent','pagetitle')));

Does this help?

@andchir
andchir commented Feb 10, 2017

I disabled the setting "only_full_group_by" and it solved the problem.
http://stackoverflow.com/questions/23921117/disable-only-full-group-by
You can close this task. Thank you all.

@OptimusCrime
Contributor

@andchir Reason @Jako asked this is to fix the issue for future incidents. Think we better leave this open until we have fixed this with only_full_group_by turned on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment