mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
FR: Support databases with limitations/stack overflow in lists - I'll provide the PRs #5990
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kafoso on GitHub (Jun 18, 2018).
Feature Request
Summary
Some database systems have a limit to how many elements are allowed in a list, e.g. an
INstatement. Proposition: SplitINstatements into severalINstatements separated byORin chunks of a certain size (from%s IN (%s)to(%s IN (%s) OR %s IN(%s) ...)).If this proposition is accepted, I will provide pull requests for all necessary versions of the Doctrine DBAL, applying the described changes.
There is no backward compatibility breakage.
Request details
Some database systems have a limit to how many elements are allowed in a list, e.g. an
INstatement. Firebird (https://firebirdsql.org/), for instance. When exceeding 1500 (or 1499 due to a bug (source)) elements in a list the error looks like the following in Firebird:This error occurs when data is extracted through the Doctrine ORM and when relations (OneToMany, etc.) contain the IDs of more than 1500 elements. Granted, it's a lot of relations, but nonetheless it's a case which causes a hard error/exception. And it's fixable.
Firebird Driver for Doctrine DBAL
I have implemented a stand-alone Firebird Driver for the Doctrine DBAL. You can review it here: https://github.com/kafoso/doctrine-firebird-driver
Proposition
Split
INstatements into severalINstatements separated byORin chunks of a certain size (from%s IN (%s)to(%s IN (%s) OR %s IN(%s) ...)).At a quick glance, it appears the list logic occurs in
Doctrine\ORM\Persisters\Entity\SingleTablePersister->getSelectConditionDiscriminatorValueSQL()in version 2.4. I will, of course, thoroughly go through this, but I won't waste my time should the proposition be rejected.If the above is the case, I propose the below change.
The platform interface (
\Doctrine\DBAL\Platforms\AbstractPlatform) will be expanded with this:The extending class (e.g.
\Kafoso\DoctrineFirebirdDriver\Platforms\FirebirdInterbasePlatform) may then provide an integer to enable chunking.Doctrine\ORM\Persisters\Entity\SingleTablePersister->getSelectConditionDiscriminatorValueSQL()will be changed to:Logic may need to be adapted to other versions of the Doctrine DBAL, particularly those requiring PHP 7+.
I will, if the proposition is accepted, provide a pull request for version 2.4. Once reviewed and accepted, I will provide pull requests for other versions as well.
Yay or Nay?
@Majkl578 commented on GitHub (Jul 4, 2018):
@morozov WDYT?
@morozov commented on GitHub (Jul 5, 2018):
Some databases also have limitations on the number of bound parameters, it should be taken into account. I think it’s worth a try.