Bug 20521: Enable problematic SQL modes for dev installs
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 4 Apr 2018 19:28:53 +0000 (16:28 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 17 Oct 2018 14:00:52 +0000 (14:00 +0000)
So far we have bug 17258 (omnibus to list the issue we have with the new
default SQL modes), bug 20144 (which fixed our test suite with these
modes) and bug 20229.
This last one forces the SQL modes to avoid to modify the DBMS
configuration and define the SQL modes we support.

We should let developers catch the issues and report/fix them.
Also Jenkins must alert us if there is a regression with the test suite.

I suggest to enable the problematic SQL modes on dev installs.

Test plan:
- Revert commit 0180524bb9b1464c441bb1b858d0d8df37524d72
- prove t/db_dependent/Koha/Biblios.t

=> If you have dev_install defined in your Koha config file, the test
will fail with "Field 'datecreated' doesn't have a default value"
=> If you do not have dev_install, the tests will pass

NOTE: The commit number was wrong. Using
    git log -- t/db_dependent/Koha/Biblios.t
    This showed bug 20176 which was 524eab678833b2719187e67128ee4f83a2a48ba4
    Also dev_install was in koha_conf.xml already, so I just had to
    toggle 0 and 1.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

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

Koha/Database.pm

index c92056c..490839b 100644 (file)
@@ -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('dev_install') ) {
+            $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';";