Problem/Motivation
Databases on different versions have different capabilities. There is not a consistent pattern for how to do this in the Core database abstraction layer DBTNG. This is a hard problem that we have ignored for Drupal 8's life cycle, and most likely an improvement for Drupal 9's life cycle.
The PDO layer has some constants to pass in when opening a connection, but some things are not detectable unless the database version is known and a query made to the database.
Being able to detect capabilities will be important for:
- Adding JSON support to change data serialization so that SQLite can fallback or PostgreSQL can use native JSONB methods in queries.
- Adding newer SQL functionality such as UPSERT for those drivers that support it.
- Improving transaction isolation level support
- ...
There are a few different scenarios:
- Capabilities prior to opening a connection (SSL, database string, SQLite placeholder limitation)
- Capabilities detectable when a connection is open (implicit commit support, driver extensions)
- Capabilities that allow for custom SQL schema and storage (JSON)
- Capabilities that allow for custom SQL language features (PostgreSQL JSONB conditions, MySQL Group By)
doctrine/dbal implements this by separating the "driver" from the "platform".
Proposed resolution
TBD
Remaining tasks
- Break down the issue into relevant resolutions to solve use cases.
- Consensus on the best approach for Drupal core going forward.
- Write a patch
API changes
Yes.
Data model changes
Hopefully not.
Comments
Comment #2
mradcliffeI couldn't find an existing issue when searching for "feature" or "capability" or "detect" other than my comments in other issues so I'm opening up this. Also based on my ideas issue.
This could be more of a meta/discussion issue.
Comment #3
mondrakeSome ideas in this sense were put in #2657888-14: Add Date function support in DBTNG.