From cbb6605d632eba95599704fc3867c11f6947d531 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Oct 2018 11:07:02 -0300 Subject: [PATCH] Bug 20521: Use a specific config for strict sql modes To avoid disrupting testers and new developers it will be turned off by default. We will turn it on for Jenkins so devs will have to take care of the regressions they introduce (!) Signed-off-by: Nick Clemens (cherry picked from commit 17e5691daaa0f6b73623198eded648c78e40056a) Signed-off-by: Martin Renvoize --- Koha/Database.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/Database.pm b/Koha/Database.pm index c92056c170..56ffc46488 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -76,7 +76,11 @@ sub _new_schema { %encoding_attr = ( mysql_enable_utf8 => 1 ); $encoding_query = "set NAMES 'utf8mb4'"; $tz_query = qq(SET time_zone = "$tz") if $tz; - $sql_mode_query = q{SET sql_mode = 'IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'}; + unless ( C4::Context->config('strict_sql_modes') ) { + $sql_mode_query = q{SET sql_mode = 'IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'}; + } else { + $sql_mode_query = q{SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'}; + } } elsif ( $db_driver eq 'Pg' ) { $encoding_query = "set client_encoding = 'UTF8';"; -- 2.39.5