From bb6ea924e8f4d9a2d1e4f478212e6c12566e9d74 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Thu, 21 Jun 2018 22:59:09 +0100
Subject: [PATCH] Issue #2875679 by mondrake, daffie:
 BasicSyntaxTest::testConcatFields fails with contrib driver

---
 .../Core/Database/BasicSyntaxTest.php         | 21 ++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
index 17f8ebb92c94..837b8ea0364d 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
@@ -29,15 +29,22 @@ public function testConcatLiterals() {
 
   /**
    * Tests string concatenation with field values.
+   *
+   * We use 'job' and 'age' fields from the {test} table. Using the 'name' field
+   * for concatenation causes issues with custom or contrib database drivers,
+   * since its type 'varchar_ascii' may lead to using field-level collations not
+   * compatible with the other fields.
    */
   public function testConcatFields() {
-    $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', [
-      ':a1' => 'The age of ',
-      ':a2' => ' is ',
-      ':a3' => '.',
-      ':age' => 25,
-    ]);
-    $this->assertIdentical($result->fetchField(), 'The age of John is 25.', 'Field CONCAT works.');
+    $result = $this->connection->query(
+      'SELECT CONCAT(:a1, CONCAT(job, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', [
+        ':a1' => 'The age of ',
+        ':a2' => ' is ',
+        ':a3' => '.',
+        ':age' => 25,
+      ]
+    );
+    $this->assertSame('The age of Singer is 25.', $result->fetchField(), 'Field CONCAT works.');
   }
 
   /**
-- 
GitLab