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
Comment | File | Size | Author |
---|---|---|---|
#9 | 2875679-9.patch | 1.44 KB | mondrake |
#9 | interdiff_2-9.txt | 1.44 KB | mondrake |
Comments
Comment #2
mondrakePatch.
Comment #5
borisson_This issue mentions that it fails with a contrib driver, what driver is causing the problem?
Comment #6
mondrakeI'm using this patch in CI testing on Travis for an experimental Doctrine DBAL driver, https://github.com/mondrake/drudbal.
Comment #7
borisson_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.
Comment #8
daffie CreditAttribution: daffie commentedCan 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.
Comment #9
mondrake#8 done.
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).
Comment #10
daffie CreditAttribution: daffie commented@mondrake: Thanks for the new patch!
It looks now good to me.
Comment #13
catchThis 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!