Skip to content

Commit

Permalink
Mention MySQL sql_mode in the docs.
Browse files Browse the repository at this point in the history
If it helps just one person avoid getting bitten by MySQL's default data-munging
retardedness, it'll have been worth it.
  • Loading branch information
bigpresh committed May 14, 2012
1 parent 1df3105 commit aa3c180
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Dancer/Plugin/Database.pm
Expand Up @@ -379,7 +379,19 @@ documentation for these.
The optional C<on_connect_do> setting is an array of queries which should be
performed when a connection is established; if given, each query will be
performed using C<< $dbh->do >>.
performed using C<< $dbh->do >>. (If using MySQL, you might want to use this to
set C<SQL_MODE> to a suitable value to disable MySQL's built-in free data loss
'features', for example:
on_connect_do: "SET SQL_MODE='TRADITIONAL'"
(If you're not familiar with what I mean, I'm talking about the insane default
behaviour of "hmm, this bit of data won't fit the column you're trying to put it
in.. hmm, I know, I'll just munge it to fit, and throw a warning afterwards -
it's not like you're relying on me to, y'know, store what you ask me to store".
See L<http://effectivemysql.com/presentation/mysql-idiosyncrasies-that-bite/> for
just one illustration. In hindsight, I wish I'd made a sensible C<sql_mode> a
default setting, but I don't want to change that now.)
The optional C<log_queries> setting enables logging of queries generated by the
helper functions C<quick_insert> et al in L<Dancer::Plugin::Database::Handle>.
Expand Down

0 comments on commit aa3c180

Please sign in to comment.