Alex Fortuna wrote:
> I need to execute a "SET SQL_MODE='STRICT_ALL_TABLES'" after my
> application's DB connection is established by AcriveRecord. This is
> important since I want the DB itself be more strict about logical data
> integrity.
>
> Which is the proper place within application code from where I can issue
> this query?
>
>
> Tried to make an ActiveRecord::Base.connection.execute() in an
> initializer, but it only runs once after server startup. At next request
> the connection is re-created, but initializers aren't invoked.
In 2.2.2 there doesn't seem to be a callback when a connection
is established & re-established, so try an initializer like
ActiveRecord::ConnectionAdapters::MysqlAdaptor.class_eval do
private
def connect_with_strict
connect_without_strict
execute "SET SQL_MODE='STRICT_ALL_TABLES'"
end
alias_method_chain :connect, :strict
end
--
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---