From f59b50258422cfee3de6607b75b420c6b793675d Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 16 Dec 2021 12:41:06 +0100
Subject: [PATCH] Bug 29648: Allow tables_settings.default_display_length to be
 NULL

We actually want this value to be NULL. If set to NULL and
default_display_length is not in the yml, then the option will not be
displayed.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
---
 installer/data/mysql/atomicupdate/bug_29648_2.pl | 14 ++++++++++++++
 installer/data/mysql/kohastructure.sql           |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100755 installer/data/mysql/atomicupdate/bug_29648_2.pl

diff --git a/installer/data/mysql/atomicupdate/bug_29648_2.pl b/installer/data/mysql/atomicupdate/bug_29648_2.pl
new file mode 100755
index 0000000000..555fb676e7
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_29648_2.pl
@@ -0,0 +1,14 @@
+use Modern::Perl;
+
+return {
+    bug_number => "29648",
+    description => "Allow tables_settings.default_display_length to be NULL",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        $dbh->do(q{
+            ALTER TABLE tables_settings
+            MODIFY COLUMN default_display_length smallint(6) DEFAULT NULL
+        });
+    },
+}
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index ccafdbafca..f8bfc30377 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -5020,7 +5020,7 @@ CREATE TABLE `tables_settings` (
   `module` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
   `page` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
   `tablename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
-  `default_display_length` smallint(6) NOT NULL DEFAULT 20,
+  `default_display_length` smallint(6) DEFAULT NULL,
   `default_sort_order` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   PRIMARY KEY (`module`(191),`page`(191),`tablename`(191))
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 
2.20.1