The SQLite date handling is wrong and needs some love and care. The handling of arguments is not prefect and needs to have workaround for the expansion of numeric values in the SQL statement, since http://bugs.php.net/bug.php?id=45259 is still unresolved. The handling of arguments will now be done by SQLite's Connection::expandArguments and as a result SQLite's Statement class can be removed. For the argument handling are some extra tests added.
The SQLite date handling and the creation of a arguments override function is combined because the SelectPagerDefaultTest only passes if both problems are fixed.
Solution
- Update the SQLite date handling
- Create SQLite Connection::expandArguments override function
- Remove the SQLite statement class. The default database statement class works just fine for SQLite.
Testing
php ./scripts/run-tests.sh --dburl sqlite://localhost/sqlite/db.sqlite --class 'Drupal\system\Tests\Database\ConnectionUnitTest','Drupal\system\Tests\Database\SelectPagerDefaultTest'
There should be no fails and no exceptions.
Commit credits
Please give @sun commit credits for this issue. All the code from the patch from the first comment is originally written by @sun.
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff.txt | 782 bytes | amateescu |
#9 | 2428695-9.patch | 14.21 KB | amateescu |
#4 | interdiff.txt | 1.57 KB | amateescu |
#4 | 2428695-4.patch | 14.2 KB | amateescu |
#1 | 2428695-1.patch | 14.01 KB | daffie |
Comments
Comment #1
daffie CreditAttribution: daffie commentedComment #2
daffie CreditAttribution: daffie commentedIf I run the test locally I get the following result:
Comment #3
daffie CreditAttribution: daffie commentedThis issue is the last one for the critical issue #2318191: [meta] Database tests fail on SQLite.
Comment #4
amateescu CreditAttribution: amateescu commentedI reviewed this patch and I just found a few minor problems, fixed with the interdiff attached.
Comment #5
alexpottI get fails when running
Drupal\system\Tests\Database\ConnectionUnitTest
with this patch.Comment #6
alexpottAlso this fix causes no postgres fails in
Drupal\system\Tests\Database\QueryTest
...Comment #7
amateescu CreditAttribution: amateescu commentedRe #5: Yes, that's documented as a failing test with this patch applied in this issue of the new SQLite meta: #2454747: SQLite: Fix sub-system tests in system test group.
The problem there is that the prefix on SQLite will never be the same as the one for MySQL and PostreSQL because the sqlite driver adds a period suffix to it in the constructor of its Connection class. In order to fix the test, we need to either provide a driver-specific test override or we can make the test smarter, but I think that's best to be discussed in the issue mentioned above.
Re #6: Since the new test works for MySQL and SQLite, should we open a new issue to fix it in the Postgres db driver?
Comment #8
alexpottRe #7/#6 this causes the postgres fails so I think not.
Comment #9
amateescu CreditAttribution: amateescu commentedI looked into why this new test fails on PostgreSQL and it seems that the return value for comparison operators is boolean TRUE/FALSE on Postgres and 1/0 on MySQL, so the current assertions will never work on all engines.
But the intention of the test is to check the expansion of numeric arguments (i.e. :count expands to 3), not the return value of comparison operators, so we can just tweak the assertions a bit.
Comment #10
alexpottThis issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 0fafbc3 and pushed to 8.0.x. Thanks!
Comment #12
amateescu CreditAttribution: amateescu commentedThe assertion from #2318191: [meta] Database tests fail on SQLite that SQLite's custom PDO statement is not needed anymore was false, so this patch is being reverted and a proper fix is implemented in #2465633: Bring back the custom Statement class for the SQLite driver.