Drupal\system\Tests\Database tests + closely related tests do not pass on SQLite.
For multiple reasons, in prioritized order:
SQLite: StatementPrefetch is not used and dead code due to logic error.
Database\Connection. Its constructor intends to override
$statementClass, but only does so after calling the parent constructor. The parent constructor immediately sets the
PDO::ATTR_STATEMENT_CLASSattribute on the connection.
In turn, SQLite uses the regular
Drupal\Core\Database\Statementclass. None of the custom SQLite code - including
StatementPrefetch- is ever called.
In addition, the former
StatementPrefetchapproach is no longer compatible with PHP core. PDO immediately throws an exception stating that a "user-supplied statement class must derive from
However,proves that the workaround is no longer necessary and obsolete. SQLite works perfectly fine with the regular
The only workaround that is still required is the expansion of numeric values in the SQL statement, since http://bugs.php.net/bug.php?id=45259 is still unresolved.
→ Expand the arguments in the SQLite
Connectionclass already. Remove all other workarounds (dead code).
New coverage is added to Database tests.
Insertquery does not account for
INSERT FROM ... SELECT.
The driver-specific optimization for
DEFAULT VALUESincorrectly kicks-in, because
Insertquery to account for a non-empty
REGEXPuser function exists, but is wrongly implemented.
The current user function was implemented after SQLite's native
regexp(subject, pattern)function, but the
string REGEXP patternSQL operator results in
regexp(pattern, subject)(reversed arguments).
→ Fix the arguments.
Covered by SelectTest::testRegexCondition().
SQLite does not interpret
'\_'as a string literal in
At the same time, MySQL breaks with
LIKE ... ESCAPE '\'.
LIKEare required to use the Select query builder, which handles the situation via
Config\DatabaseStorage::listAll()does not use the Select query builder.
→ Use a proper Select query builder in
SQLite does not natively support
Used by Views, also in D8.
CONCAT_WS()is not ANSI SQL, but is supported by MySQL + PostgreSQL, and can be easily supported in SQLite.
New coverage is added to Database tests.
SQLite's date/calendar handling is limited.
SQLite does not support advanced date/calendar operations (such as identifying 2000-01-01 as the 52nd week of 1999).
→ The affected test of Views won't ever pass on SQLite and needs to be wrapped into a database driver condition.
- Make qa.drupal.org testbots additionally execute all Database tests against SQLite when testing Drupal core.
- Add the corresponding fixes.
Why the changes to run-tests.sh?
The approach was discussed in recent meetings for modernizing the testbot already.
Databasecomponent that claims to support multiple backends, so proving that claim means to run only the
Databasetests against more than one backend — a.k.a. explicit test coverage. (1 min 13 sec)
run-tests.shis adjusted to check whether it is executed on a qa.drupal.org/PIFR testbot and asked to run the full Drupal core test suite (
Only if both conditions are met,
Databasetests are executed against SQLite prior to the actual core test suite (which still runs against MySQL).
Test failures in SQLite do NOT affect the final test result. For now, test results are only visible in the test review log and not recorded (i.e.,
--keep-resultsis explicitly disabled).
This is how backend-specific component testing is supposed to work and how it's done everywhere else. That's why the application should have total control over the CI test/build script and why the same approach is found in Travis-CI (working example).
Once we fully migrated to PHPUnit, the executed operation will look like this:
$ DRUPAL_DATABASE=sqlite://localhost/build/db.sqlite phpunit -c core --group Database
run-tests.sh, this will run all tests tagged with
@group Database; i.e., including Database backend tests of other components.)
Why a single issue?
As soon as you swap out the Database driver, all errors are exposed.
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 85,126 pass(es). View
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 84,322 pass(es). View
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Failed to run tests: PHP Fatal error encountered during run_tests.sh. See review log for details.. View