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

Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause (locally only) #3120

Closed
jywarren opened this issue Jul 21, 2018 · 5 comments
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed

Comments

@jywarren
Copy link
Member

jywarren commented Jul 21, 2018

My local instance is seeing the same error we saw on June 7 (#2787 (comment)) that I thought we fixed in #2794

Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'plots.node_revisions.vid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT node_revisions.* FROM node_revisionsINNER JOINnodeONnode.nid=node_revisions.nid WHERE (type = ('page')) AND (node.status = 1) AND (node_revisions.status = 1) AND (timestamp - node.created > 300) GROUP BY node.title, node.nid ORDER BY timestamp DESC LIMIT 10

On line 127 of home_controller.rb, but really to do with the preceding ActiveRecord call:

revisions = Revision.joins(:node)
.order('timestamp DESC')
.where('type = (?)', 'page')
.where('node.status = 1')
.where('node_revisions.status = 1')
.where('timestamp - node.created > ?', 300) # don't report edits within 5 mins of page creation
.limit(10)
.group(['node.title', 'node.nid'])

I'm going to try tweaking locally to get past it.

@jywarren jywarren added the bug the issue is regarding one of our programs which faces problems when a certain task is executed label Jul 21, 2018
@jywarren
Copy link
Member Author

This seems to say that any column/field we select MUST be in the GROUP_BY call too. Weird, because we don't use select near here, only up on line 93:

.select('node.*, term_data.*, community_tags.*')

@jywarren
Copy link
Member Author

But ActiveRecord produces a select from our query, the full query being:

SELECT `node_revisions`.* FROM `node_revisions` INNER JOIN `node` ON `node`.`nid` = `node_revisions`.`nid` WHERE (type = ('page')) AND (node.status = 1) AND (node_revisions.status = 1) AND (timestamp - node.created > 300) GROUP BY node.title, node.nid ORDER BY timestamp DESC LIMIT 10

@jywarren
Copy link
Member Author

jywarren commented Jul 21, 2018

Also noting that the default for the ONLY_FULL_GROUP_BY setting changed from off to on in MySQL 5.7, so we may have some version mismatch issues here, but i'll fix it on my local anyways. Which is:

mysql Ver 14.14 Distrib 5.7.21, for Linux (armv7l) using EditLine wrapper

@jywarren
Copy link
Member Author

jywarren commented Jul 21, 2018

OK, adding a commit to #2925 to resolve this! 4544dc5

jywarren added a commit to cheneyshreve01/plots2 that referenced this issue Jul 21, 2018
jywarren pushed a commit that referenced this issue Jul 21, 2018
…ymbol #2913 (#2925)

* initial setup commit

* [WIP] updated emoji to read from static file, upstream fetch & rebase

*  [WIP] added autocomplete username to comment window using atwho library

* [WIP] Add autocompleting usernames with @ symbol #2913 fixed typo

* [WIP] refactoring atwho calls

* finished refactoring using API call, adjusted indentations

* removed unnecessary example file

* [WIP] testing hashtag_config behavior, removed unnecessary files

* [WIP] refactored hash_config, removed unnecessary file, set limits for dropdowns

* [WIP] updated emoji code, rebased, removed unneccessary file

* [WIP] removed unneccsary atwho code from application_helper.rb

* updated hash call with conditional, removed query from emoji call, set limit for at callbacks to 20

* emoji fixes

* resolved #3120 ONLY_FULL_GROUP_BY issue w/ mysql 5.7+
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this issue May 5, 2019
…ymbol publiclab#2913 (publiclab#2925)

* initial setup commit

* [WIP] updated emoji to read from static file, upstream fetch & rebase

*  [WIP] added autocomplete username to comment window using atwho library

* [WIP] Add autocompleting usernames with @ symbol publiclab#2913 fixed typo

* [WIP] refactoring atwho calls

* finished refactoring using API call, adjusted indentations

* removed unnecessary example file

* [WIP] testing hashtag_config behavior, removed unnecessary files

* [WIP] refactored hash_config, removed unnecessary file, set limits for dropdowns

* [WIP] updated emoji code, rebased, removed unneccessary file

* [WIP] removed unneccsary atwho code from application_helper.rb

* updated hash call with conditional, removed query from emoji call, set limit for at callbacks to 20

* emoji fixes

* resolved publiclab#3120 ONLY_FULL_GROUP_BY issue w/ mysql 5.7+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed
Projects
None yet
Development

No branches or pull requests

1 participant