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
FieldFieldTest fails currently with PostgreSQL as database backend.
The test fails because the PostgreSQL return value is '0' instead of an empty string ''.
Value '' is identical to value '0'.
Proposed resolution
Use assertEqual() instead of assertIdentical() as we already did in other tests.
Remaining tasks
Review patch.
User interface changes
None.
API changes
None.
Beta phase evaluation
Issue category | PostgreSQL Bug |
---|---|
Issue priority | Major |
Prioritized changes | PostgreSQL fix that changes test data only. |
Disruption | None |
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff.txt | 1.26 KB | amateescu |
#14 | 2484539-14.patch | 1.35 KB | amateescu |
#2 | 2484539.patch | 616 bytes | amateescu |
Comments
Comment #1
dawehnerDo you mind posting the result output, maybe for example the which is failing? Its a bit non trivial to follow what went wrong.
Comment #2
amateescu CreditAttribution: amateescu for Drupal Association commentedWe have a few similar assertions in that test, and the previous ones use
$this->assertEqual(0, ...);
instead of the currentassertIdentical()
.I can not reproduce the test fail on my local install with SQLite, but the patch attached fixes Posgres. Let's try a mysql testbot run :)
Comment #3
amateescu CreditAttribution: amateescu for Drupal Association commentedHere's an example of the same assertion that already exists in that test: http://cgit.drupalcode.org/drupal/tree/core/modules/views/src/Tests/Hand...
Comment #4
bzrudi71 CreditAttribution: bzrudi71 commentedIS update.
Comment #5
dawehnerSo the rendered result changes on a different database? WOW
It seems to be for me that this is though not the absolute right fix, why, views has a feature to hide a field in case its empty (or optionally also 0).
Is there really no way to ensure that both databases have a similar behaviour ?
Comment #6
bzrudi71 CreditAttribution: bzrudi71 commentedAgreed, in that case we should ensure the same behavior for PG as well. What makes me wonder is that we have dozens of unit tests for 'hide_empty' testing and they all pass PG. Seems we need to debug a bit further...
Comment #7
dawehnerGood question, I was wondering this as well.
Comment #8
mradcliffeI can only think of doing a COALESCE as an alternative, but that seems to me to be even more weird.
Comment #9
mradcliffeI think this is happening somewhere between entity/field loading as this view, per @dawehner, is fetching the id and loading entities to compare against.
I'm changing to Needs Work based on #4, #5, and #6.
Comment #10
amateescu CreditAttribution: amateescu for Drupal Association commentedYes, I also think that using COALESCE would be the solution to fix Views' queries, but this issue is just about fixing a test fail introduced in Postgres and SQLite by #1867518: Leverage entityDisplay to provide fast rendering for fields.
Like I said in #2, the patch is just changing an assertion to match all the others from the same test file, and it fixes the test on Postgres and SQLite so can we please discuss improving Views in a different issue? :)
Comment #11
dawehnerAs @mradcliffe said, this is a really odd behaviour, I think we should fix the actual problem and not just the test. There is no reason that you expect "0" to be rendered in that case,
so you effectively bypass a bug here.
Comment #12
amateescu CreditAttribution: amateescu for Drupal Association commentedThe bug was there before #1867518: Leverage entityDisplay to provide fast rendering for fields (and it most likely exists in Views 7.x as well) and *a lot* of assertions from this test class are already bypassing it, see an identical one here: http://cgit.drupalcode.org/drupal/tree/core/modules/views/src/Tests/Hand...
I really don't understand why we would want to block this issue on refactoring Views queries. If we had SQLite and Postgres testing, #1867518: Leverage entityDisplay to provide fast rendering for fields wouldn't have introduced the failing test in the first place, and this is just a small followup to cleanup after that patch...
Comment #13
catchSo I don't think we should block this patch on the views fix - because once we get to 100% pass on sqlite and/or postgres, it's going to be much easier to spot other regressions introduced elsewhere, that's more important than the rendering discrepancy.
However we do need an at-least-major issue for the rendering discrepancy and we should document here that the test is working around that.
Comment #14
amateescu CreditAttribution: amateescu for Drupal Association commentedOpened the major follow-up and linked it in the test code. #2488006: Views' Field handler returns different output depending on the database driver
Comment #15
dawehnerFair deal!
Comment #16
alexpottI've run the test on postgres, mysql, and sqlite and it passes - nice. Committed 47f69d8 and pushed to 8.0.x. Thanks!