Problem/Motivation

The 'test' table in the database test module is created with the 'name' column defined as type 'varchar_ascii', while the table collation used is 'utf8mb4_general_ci'. This results in the 'name' column to use a 'ascii_bin' collation, different than the rest of the columns.

When BasicSyntaxTest::testConcatFields is concatenating db fields and literal constants under a driver that implements a mysqli statement, the following exception is thrown:

Drupal\Core\Database\DatabaseExceptionWrapper: Illegal mix of collations (ascii_bin,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat': SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age; Array
(
    [:a1] => The age of 
    [:a2] =>  is 
    [:a3] => .
    [:age] => 25
)

Apparently, mysqli is stricter than PDO in this case.

Proposed resolution

The simplest proposal is to just replace 'name' with 'job' in the test: 'job' has the same collation of the rest of the fields/literals at that point.

Remaining tasks

review

User interface changes

none

API changes

none

Data model changes

none

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
FileSize
1.01 KB

Patch.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

This issue mentions that it fails with a contrib driver, what driver is causing the problem?

mondrake’s picture

I'm using this patch in CI testing on Travis for an experimental Doctrine DBAL driver, https://github.com/mondrake/drudbal.

borisson_’s picture

Awesome, thanks! I tagged this with subystem maintainer review because I don't know enough about the database system to have an opinion about wether this is a good fix.

daffie’s picture

Status: Needs review » Needs work
Issue tags: -Needs subsystem maintainer review +Needs framework manager review

Can we add some documentation about this problem by the test. The problem for me is that it will remain an ugly little problem. Changing this test will not be the last time that some Drupal developer will run into this problem if we are going to use the Doctrine DBAL drivers. With the added documentation I will give it RTBC.

We do not have a subsystem maintainer any more after @crell left. So changing it to the framework maintainer.

mondrake’s picture

#8 done.

Changing this test will not be the last time that some Drupal developer will run into this problem if we are going to use the Doctrine DBAL drivers.

Well the problem is more general, regardless of Doctrine DBAL or not, and has to do with making the codebase db-agnostic (see #2877583: [Meta] Remove database specific logic from core) and the test suite running for non-core drivers (see #2605284: Testing framework does not work with contributed database drivers).

daffie’s picture

Status: Needs review » Reviewed & tested by the community

@mondrake: Thanks for the new patch!

It looks now good to me.

  • catch committed bb6ea92 on 8.6.x
    Issue #2875679 by mondrake, daffie: BasicSyntaxTest::testConcatFields...

  • catch committed 60cb80b on 8.5.x
    Issue #2875679 by mondrake, daffie: BasicSyntaxTest::testConcatFields...
catch’s picture

Version: 8.6.x-dev » 8.5.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs framework manager review

This looks fine, the comment explains why we're making the change.

Committed/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.