Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

(#16333) Override function in AR MySQL connector to set sql_mode #120

Merged
merged 2 commits into from
Nov 26, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/initializers/mysql_session_sql_mode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ActiveRecord::ConnectionAdapters
class MysqlAdapter
alias :configure_connection_old :configure_connection
def configure_connection
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably isn't a good idea - better to rename the previous method, and call it, so that additional behaviour (which at least some versions do have) is also preserved.

# Explicitly set the SQL mode for the session in case there are problematic global settings
execute("SET @@SESSION.sql_mode='TRADITIONAL'")

configure_connection_old()
end
end
end