Active
Project:
Drupal core
Version:
main
Component:
database system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Jan 2017 at 16:34 UTC
Updated:
28 May 2025 at 07:17 UTC
Jump to comment: Most recent
Comments
Comment #2
mradcliffeChanged title slightly.
Comment #3
mradcliffeAdded link to @mondrake's drudbal project on github.
Comment #4
mradcliffeComment #5
yoroy commentedThis is very far from my area of expertise, so some general questions:
- Is this potentially an all-or-nothing rework of a big subsystem or are there ways towards meaningfull incremental changes?
- If the latter: what are the main pain points to tackle?
- What do we need to know to be able to identify where to start?
It would be good to hear from more people who run into limitations.
Comment #6
yoroy commentedComment #7
rivimey@yoroy, @mradcliffe,
I believe this could be done, and it certainly seems that Doctrine/DBAL is well thought out. The DBTNG is not bad at all, but does indeed have its faults.
I think the issues mentioned in the motivation section would, however, need to be addressed separately; use of D/DBAL is not going to fix them all even if it's fully implemented.
My experience to date is still mostly D7, but the major points from that are:
- over-reliance on weakly typed variables and poor design/use of Interfaces. I expect this is a lot better in D8.
- Lowest common denominator approach, especially not using stored procedures and views to better effect (because it is usually hard to predict what to do in advance). I would like to see more granular approach taken.
As for test frameworks, new driver discovery: well almost by definition that's going to be hard. Even if you can discover that a new driver is available for the test, normally the database will not be available on the test machine, and doing that in any automatic way is not something I would want to see done on the testbots because of the security issues.
It is hard to see whether e.g Doctrine/DBAL can be implemented progressively, but I would suggest that if it's not it will be a very hard sell. Perhaps a compatibility layer can be set up to enable db_query, db_select et al into DBAL? Perhaps DBTNG can be extended with a Doctrine driver? Then those wishing to use and expose Doctrine functionality can do so.
Comment #8
giorgio79 commentedPossibly a dupe of #1817778: Consider using Doctrine ORM for Entities
Comment #9
mradcliffeNot a duplicate. This issue is a meta/plan around DBAL in core. #1817778: Consider using Doctrine ORM for Entities is a specific action to implement one of the items in this idea.
I've added that issue to the issue summary.
Comment #10
sarmiliboyz commented+1 for doctrine as dbal, so Drupal can use more db engine
Comment #11
pfrenssenComment #12
mradcliffeOpened #3080133: Add a way for a driver to detect features/capabilities supported in the connection or driver for looking at adding capability detection to DBTNG for all the various scenarios of capabilities.
Comment #13
mradcliffeI thought about this more this week.
Some basic criteria:
I think this leaves us an opportunity
This is a work-in-progress. I'm task switching a bit today so I'm going to post this and come back to it later. I'm working on a flow chart to describe this.
Comment #14
colorfulcoder commentedRemoved the abbreviation in the title (full words are more clear) and changed the abbrivation (DBTNG) to DBAL.
Comment #15
ghost of drupal pastThis issue is all the more pressing with MySQL and MariaDB diverging.
Comment #16
daffie commentedComment #17
daffie commentedThe problem
The situation that we now have is that there are 3 by core supported databases with for each a driver directory. The idea was that for each supported database a driver directory would be enough. The problem only that that is not the case. There are a number of exceptions where code for a specific database is in core and not in the driver directory. Contrib database drivers also have those exceptions and core does not want to have the contrib database code in core. For an example see #2009238: CONCAT_WS is not compatible with all database drivers. The views subsystem maintainer (@lendude) does not want code for contrib databases in "his" views module. And if I were the views subsystem maintainer I would not want that either. That makes creating a contrib database driver with only the driver directory impossible. So how can we solve the problem? We should give all database drivers module capabilities. The ones supported by core and the contrib ones. It would create a solid base to solve all the problems mentioned in the issue summery.
The plan
Statuses for contrib database drivers
Examples
If you now want to create contrib PostgreSQL driver with JSON capabilities you:
- create a new contrib database driver;
- extend all the classes from the core PostgreSQL driver;
- add the JSON functionality.
And you are done. If we add the contrib driver testbot we can also test if it all works.
Maybe a custom testbot is needed for testing against a newer version of PostgreSQL.
If you now want to create contrib MariaDB driver you:
- create a new contrib database driver;
- extend all the classes from the core MySQL driver;
- add the specific MariaDB code.
And you are done. If we add a custom contrib driver testbot with a MariaDB database we can test if it all works.
If you want to convince that core can work with Doctrine ORM for entities, you:
- create a new contrib database driver;
- extend all the classes from the core MySQL driver;
- add the specific Doctrine ORM code.
And you are done. If we add the contrib driver testbot we can also test if it all works.
We can then more easily see and discuss what needs to be changed for the move to Doctrine ORM for entities.
Comment #18
ghost of drupal pastWhich is why
backend_overridabletagged services exist, see #2302617: Define a standard mechaism for backend-aware service overrides and the relevant change notice linked from there.Comment #19
daffie commented@chx: Those
backend_overridableservices are great. Thank you and @Crell for creating them. Maybe I am missing your point, but I will still need an mongodb.services.yml for my aliases and a location for my file that holds the class implementation. And the driver directory is for me the wrong directory, it is just not part of the driver.Second: What I also want is that site builders can easily use composer to get my MongoDB for Drupal.
At the moment that is not possible.
Third: I need to override plugin classes. For that I will need to implement a hook. And for that I will need to have a mongodb.module file. See #2009238: CONCAT_WS is not compatible with all database drivers. By your suggestion by the way @chx :-).
Making database drivers a module with the driver directory inside it, would fix those problems. And also the other problems noted in the issue summery. If you think that I am wrong or you see a better solution, then please explain.
Comment #20
daffie commented@lendude, the subsystem maintainer for the views module said in #2009238-46: CONCAT_WS is not compatible with all database drivers:
The solution that @lendude wants in "his" views module requires that the contrib database driver has module like capabilities.
Comment #21
daffie commentedComment #22
daffie commented@alexpott said in #3098426-10: EntityQueryTest::testToString fails with non-core db drivers:
A typical solution for this will result in a system with hooks or plugins. Both require that the custom database driver has module like capabilities.
Comment #23
daffie commentedComment #24
guypaddock commented+1 for going in the Doctrine/DBAL direction, if we can. That unlocks the ability to use more of the Symfony eco-system in Drupal and makes it easier to abstract interactions with the database than DBTNG is currently capable of. D8's (and, by exension, D9's) current approach to DB storage provides driver-level abstraction but the fields represented in entities are pretty much as they appear in the DB.
Comment #25
andypostComment #26
fgmWhile we're at it, if we go the DBAL way, shouldn't we consider adopting Doctrine migrations, which :
Comment #27
quietone commentedThe Ideas project is being deprecated. This issue is moved to the Drupal project. Check that the selected component is correct. Also, add the relevant tags, especially any 'needs manager review' tags.