rails/rails — pull request #8346 by sodabrew (2012-11-28 12:05:22+00:00)
Title: Add 'set_session:' param to database.yml for mysql and mysql2 adapters

mysql and mysql2 session parameters can be set in the new 'set_session:' parameter in database.yml. The key-value pairs of this hash will be sent in a 'SET key = value, ...' query on new database connections.

Consolidated the configure_connection methods from mysql and mysql2 into the abstract_mysql base class.

Example use case, database.yml:

```yaml
production:
adapter: mysql2
database: foo_prod
user: foo
set_session:
sql_mode: traditional
default_week_format: 1
```

See http://dev.mysql.com/doc/refman/5.0/en/set-statement.html and http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

I originally wanted to remove the new 'strict: boolean' parameter, and run sql_mode just from the set_session section, but turns out that strict mode also cleans up some column value behavior within the mysql adapters. So the intersection of strict and set_session sql_mode is that when strict is true, you better not override sql_mode to a setting that is less-strict -- however you _can_ override it to a value that is more strict (e.g. TRADITIONAL includes strict-mode's STRICT_ALL_TABLES plus adds a few more strictness options that many people might like!).