X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FKernelTests%2FCore%2FDatabase%2FBasicSyntaxTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FKernelTests%2FCore%2FDatabase%2FBasicSyntaxTest.php;h=837b8ea0364d0c4dc1b43ece7fd1e5a4340f0fcd;hp=53a87b7dbf9c3e55308aae40b86200ffd7ee96d2;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php b/web/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php index 53a87b7db..837b8ea03 100644 --- a/web/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php +++ b/web/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php @@ -12,6 +12,7 @@ namespace Drupal\KernelTests\Core\Database; * @group Database */ class BasicSyntaxTest extends DatabaseTestBase { + /** * Tests string concatenation. */ @@ -28,15 +29,22 @@ class BasicSyntaxTest extends DatabaseTestBase { /** * 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.'); } /**