Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
GlossaryTest fails currently with PostgreSQL as database backend. This is because some tests expect case-insensitive results but that is currently not working for PostgreSQL.
Proposed resolution
Support case-insensitive queries by using LOWER() and some other magic.
Remaining tasks
Write patch
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff.txt | 791 bytes | bzrudi71 |
#12 | 2451749-12.patch | 2.76 KB | bzrudi71 |
Comments
Comment #1
bzrudi71 CreditAttribution: bzrudi71 commentedComment #2
amateescu CreditAttribution: amateescu commentedThis is another occurrence of case sensitivity hell. I fixed it for SQLite in #2462175: SQLite: Fix case sensitivity in Views' string argument plugin but only because we managed to implement a user-space collation in #2454733: Add a user-space case-insensitive collation to the SQLite driver.
The fix here will probably depend on the outcome of #1518506: Normalize how case sensitivity is handled across database engines.
Comment #3
bzrudi71 CreditAttribution: bzrudi71 commentedThanks amateescu! Very useful information, saves the PG-Team from debugging :-)
Comment #4
amateescu CreditAttribution: amateescu commented@dawehner asked me about this issue and I think we can do something like this for PostgreSQL. Can you please try to see if it works? :)
Comment #5
dawehnerThe good looks great for me!
@bzrudi71
Now its up to you to say, whether this fixes the tests.
Comment #6
dawehnerThe good looks great for me!
@bzrudi71
Now its up to you to say, whether this fixes the tests.
Comment #7
amateescu CreditAttribution: amateescu commentedFixing the comments.
Comment #8
bzrudi71 CreditAttribution: bzrudi71 commentedThanks so much @amateescu and @dawehner for helping out here. Unfortunately tests still fail with patch applied :-( I already tried a lot of very similar approaches to force case-insensitive in StringArgument.php (like amateescu did in the SQLite fix). I think there *might* be something wrong outside StringArgument.php that we miss, or we have overseen another problem within StringArgument.php ;-)
Comment #9
amateescu CreditAttribution: amateescu commentedWhat would help a lot is if we can take a look at the query generated by the view with this patch applied. That should allow us to see what we're missing :)
Comment #10
bzrudi71 CreditAttribution: bzrudi71 commentedGuess we are talking about $view->build_info['query']?
Interested how that compares to SQLite or MySQL:
SELECT LOWER(SUBSTRING(node_field_data.title, 1, 1)) AS title_truncated, COUNT(node_field_data.nid) AS num_records, MIN(node_field_data.nid) AS nid, MIN(users_field_data_node_field_data.uid) AS users_field_data_node_field_data_uid FROM {node_field_data} node_field_data LEFT JOIN {users_field_data} users_field_data_node_field_data ON node_field_data.uid = users_field_data_node_field_data.uid GROUP BY title_truncated ORDER BY title_truncated ASC NULLS FIRST
Comment #11
bzrudi71 CreditAttribution: bzrudi71 commentedOkay, just another update after another hour of debugging. With patch applied I can get 100% pass by additionally:
1. force HandlerBase::caseTransform() to return lowercase in case of an 'upper' request
That fixes the current fails because of the 'unwanted' cache tags.
2. As soon as we have pass here we need another change in GlossaryTest around line 93 within the foreach loop to force the '$label' value to be lowercase instead of uppercase.
With that test passes but we need to check why this is needed and how to come around :) I'm finished for today so if someone else likes to have a look your invited!
[UPDATE] As a last feedback for today, the patch isn't required at all. With just the above changes we have 100% pass.
Comment #12
bzrudi71 CreditAttribution: bzrudi71 commentedSometimes it's better to have some sleep :) I found the missing part.
Comment #13
bzrudi71 CreditAttribution: bzrudi71 commentedUpdated issue summary. Just to make sure I did a complete bot run with patch applied and don't see any new fail or exception!
Comment #14
jaredsmith CreditAttribution: jaredsmith at Bluehost commentedI've reviewed the patch in comment 12, and re-run the DrupalCI testing on PostgreSQL 9.1
The patch solves the outstanding issues in the GlossaryTest test. It causes no additional regressions in the Views test group.
Before the patch:
Drupal\views\Tests\GlossaryTest 30 passes 3 fails 6 messages
After the patch:
Drupal\views\Tests\GlossaryTest 33 passes
Marking as RTBC, as I think this is ready to be reviewed by a core committer.
Comment #15
catchIs this not fixable at the database driver level? Baking the logic into Views means a contrib database driver has no way to get around the same problem.
Comment #16
jaredsmith CreditAttribution: jaredsmith at Bluehost commentedCase-insensitive matching at the database or database-driver level is being discussed in #2464481: PostgreSQL: deal with case insensitivity, but I don't think that there's any consensus yet on how to best address that, especially when we probably don't always want to do case-insensitive searches across all text fields.
Comment #17
bzrudi71 CreditAttribution: bzrudi71 commentedSetting back to needs review, because I think we have a follow up for a fix at database level with #2464481: PostgreSQL: deal with case insensitivity.
Comment #18
daffie CreditAttribution: daffie commentedI agree with jaredsmith's reply in comment #16.
The patch looks good to me. So back to RTBC.
Comment #19
bzrudi71 CreditAttribution: bzrudi71 commented@daffie thanks for review and nice to see you back again! Would you mind looking over the other open issues and leave some feedback to help moving forward there :)
Comment #20
alexpottGiven that we permitted SQLite to fix this in Views I think we should permit postgres too. We have the followup #2464481: PostgreSQL: deal with case insensitivity in place to try to address case sensitivity issue better.
Committed 7786d91 and pushed to 8.0.x. Thanks!
Comment #23
david_garcia CreditAttribution: david_garcia commentedWhen I came accross this I thought it was some very old code that needed fixing... just to find out this was commited very recently.
Why don't we ask the database abstraction layer how to do this instead of hardcoding it?
Having this kind of code diminishes drupal's portability.