Bug 21613: Turn strict SQL modes on for tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 18 Oct 2018 23:06:07 +0000 (20:06 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 29 Oct 2018 00:41:27 +0000 (00:41 +0000)
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 <strict_sql_modes>1</strict_sql_modes> 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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Database.pm

index 56ffc46..1da498f 100644 (file)
@@ -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' ) {