SyntaxConformanceTest::testSqlOperators - Fix failure on MySQL 8 #17262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before
SyntaxConformanceTest::testSqlOperators
frequently fails on theDedupe
entity when running on MySQL 8 (bknix-edge
).After
SyntaxConformanceTest::testSqlOperators
repeatedly passes for all entities on my copy of MySQL 8 (bknix-edge
).Technical Details
The
testSqlOperators
creates a small pool of example records ($entities
), then it slices/dices that pool with a few SQL operators and asserts the number of matches.In particular:
The problem is that
$entities[0]
does not necessarily have the lowest ID -- because$entities
was not fetched in any particular order. The default ordering is often the same as theid
, but not always.I suspect that this problem manifests most frequently with the
Dedupe
entity because the underlying table (civicrm_prevnext_cache
) is highly volatile (many writes+deletes) -- thus it's more likely to reuse old storage slots for new rows.IMHO, the problem ought to occur in many SQL environments, but the frequency of occurrence seems to vary by version.