From aa3c180069c5e3ad4a5c28c41f183308239d6b31 Mon Sep 17 00:00:00 2001 From: David Precious Date: Mon, 14 May 2012 23:31:55 +0100 Subject: [PATCH] Mention MySQL sql_mode in the docs. If it helps just one person avoid getting bitten by MySQL's default data-munging retardedness, it'll have been worth it. --- lib/Dancer/Plugin/Database.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Dancer/Plugin/Database.pm b/lib/Dancer/Plugin/Database.pm index edf1ba02..23d9b8ed 100644 --- a/lib/Dancer/Plugin/Database.pm +++ b/lib/Dancer/Plugin/Database.pm @@ -379,7 +379,19 @@ documentation for these. The optional C 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 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 for +just one illustration. In hindsight, I wish I'd made a sensible C a +default setting, but I don't want to change that now.) The optional C setting enables logging of queries generated by the helper functions C et al in L.