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
Append sql_mode instead of overwriting in strict mode #24167
Append sql_mode instead of overwriting in strict mode #24167
Conversation
df9d24b
to
262bd9e
Compare
sql_mode = "REPLACE(#{sql_mode}, 'STRICT_ALL_TABLES', '')" | ||
sql_mode = "REPLACE(#{sql_mode}, 'TRADITIONAL', '')" | ||
end | ||
variables['sql_mode'] = -> { sql_mode } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Treating callable values as unquoted is clever but it's not clear, particularly since we're using rescue
to handle the condition.
We could omit this from variables
and add to the set
statement ourselves, like we do with encoding config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example,
sql_mode = "@@SESSION.sql_mode = #{sql_mode_change}"
…
@connection.query "SET #{encoding} #{sql_mode} #{variable_assignments}"
ff6252e
to
eb3dcac
Compare
end | ||
sql_mode_assignment = "@@SESSION.sql_mode = #{sql_mode}, " if sql_mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitted sql_mode
from variables
and added to the set statement ourselves!
For keep the default SQL mode.
eb3dcac
to
5ad6ed9
Compare
end | ||
sql_mode_assignment = "@@SESSION.sql_mode = #{sql_mode}, " if sql_mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitted sql_mode
from variables
and added to the set statement ourselves!
…writing_in_strict_mode Append sql_mode instead of overwriting in strict mode
Thank you @kamipo! |
MySQL 5.7.5以降では、SELECT DISTINCTとORDER BYを組み合わせるとき ORDER BYで指定する列をSELECTにも含めなければならなくなった。 その結果、ログ表示画面で年月の一覧を取得するときにエラーが発生する。 データベースの設定でMySQLのSQLモードをTRADITIONALに設定することで MySQL 5.6以前と同じ挙動になるようにする。 参考文献: 1. https://blog.kamipo.net/entry/2015/12/14/171838 2. rails/rails#24167 3. rails/rails#25924 (comment)
For keep the default SQL mode.
This is an alternative of #23448.
r? @jeremy Do you think this is a good?