From 43456eec73a87b751a39103999ea81205786ae29 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Thu, 30 Jan 2025 16:30:54 +0100
Subject: [PATCH] FIX: Set character set and collation so accents are not
 ignored.

---
 CHANGELOG.md                         |  2 ++
 README_SETUP.md                      |  2 +-
 RELEASE_GUIDELINES.md                |  2 +-
 patches/patch20250130-8.0.1/patch.sh | 47 ++++++++++++++++++++++++++++
 utils/helpers.sh                     |  2 +-
 5 files changed, 52 insertions(+), 3 deletions(-)
 create mode 100755 patches/patch20250130-8.0.1/patch.sh

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b93f14a..366a97c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Fixed
 
 - [SQL dump migration can now be applied twice](https://gitlab.indiscale.com/caosdb/src/caosdb-mysqlbackend/-/issues/60): Fixed an error in the regex.
+- [linahead-server#264 Queries ignore accents and umlauts](https://gitlab.com/linkahead/linkahead-server/-/issues/264): Changed to more appropriate
+  collation and character sets.
 
 ### Security
 
diff --git a/README_SETUP.md b/README_SETUP.md
index a92db35..ec01218 100644
--- a/README_SETUP.md
+++ b/README_SETUP.md
@@ -1,4 +1,4 @@
-# Setup of the LinkAhead MariaDB back end
+# Setup of the LinkAhead MariaDB backend
 
 ## Dependencies
 
diff --git a/RELEASE_GUIDELINES.md b/RELEASE_GUIDELINES.md
index 72f4534..41c4713 100644
--- a/RELEASE_GUIDELINES.md
+++ b/RELEASE_GUIDELINES.md
@@ -1,4 +1,4 @@
-# Release Guidelines for the LinkAhead MariaDB Backend
+# Release Guidelines for the LinkAhead MariaDB backend
 
 This document specifies release guidelines in addition to the general release
 guidelines of the CaosDB Project
diff --git a/patches/patch20250130-8.0.1/patch.sh b/patches/patch20250130-8.0.1/patch.sh
new file mode 100755
index 0000000..d274e72
--- /dev/null
+++ b/patches/patch20250130-8.0.1/patch.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# This file is a part of the Linkahead Project.
+#
+# Copyright (C) 2025 IndiScale GmbH <info@indiscale.com>
+# Copyright (C) 2025 Daniel Hornung <d.hornung@indiscale.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+
+# Update mysql schema to version v8.1.0
+#
+# Set the collation so that accents on characters become relevant.
+
+NEW_VERSION="v8.0.0"
+OLD_VERSION="v8.0.1"
+
+if [ -z "$UTILSPATH" ]; then
+  UTILSPATH="../utils"
+fi
+
+. $UTILSPATH/patch_header.sh $*
+
+check_version $OLD_VERSION
+
+# Update charsets and collations.
+
+# Get all tables, drop first line, take first column
+tables=$(mysql_execute "SHOW TABLE status where Collation='utf8mb3_unicode_ci';" -B | tail +2 | awk '{print $1}')
+for table in tables; do
+    mysql_execute "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE uca1400_as_ci;"
+done
+
+update_version $NEW_VERSION
+
+success
diff --git a/utils/helpers.sh b/utils/helpers.sh
index f335dfa..ff4b189 100644
--- a/utils/helpers.sh
+++ b/utils/helpers.sh
@@ -34,7 +34,7 @@
 function mysql_execute {
 	  #TODO is it meaningful that here always the database user is used???
 	  set -e
-	  $MYSQL_CMD $(get_db_args) -e "$1"
+	  $MYSQL_CMD $(get_db_args) -e "$@"
 	  ret=${PIPESTATUS[0]}
 	  if [ "$ret" -ne 0 ]; then
 		    failure "MYSQL ERROR"
-- 
GitLab