From bab5ff0645768a1283f28d651687bd1cc6d3dfbe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Oct 2018 20:06:07 -0300 Subject: [PATCH] Bug 21613: Turn strict SQL modes on for tests This patch will turn the strict SQL modes on When tests are ran with prove. Test plan: - Apply the first patch - prove t/db_dependent/Koha/Database.t => Will pass if you have 1 in your koha-conf.xml => Will fail otherwise - Apply the second patch - prove t/db_dependent/Koha/Database.t => Will pass whatever the value of strict_sql_modes in your koha-conf.xml Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- Koha/Database.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Database.pm b/Koha/Database.pm index 56ffc46488..1da498fee4 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -76,10 +76,10 @@ sub _new_schema { %encoding_attr = ( mysql_enable_utf8 => 1 ); $encoding_query = "set NAMES 'utf8mb4'"; $tz_query = qq(SET time_zone = "$tz") if $tz; - 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 { + if ( $ENV{_} =~ m|prove| or C4::Context->config('strict_sql_modes') ) { $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'}; + } else { + $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'}; } } elsif ( $db_driver eq 'Pg' ) { -- 2.39.5