Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findBy with more than 2100 parameters generates an error in SQL Server #11603

Open
bsauvajon26 opened this issue Sep 18, 2024 · 5 comments
Open

Comments

@bsauvajon26
Copy link

bsauvajon26 commented Sep 18, 2024

Bug Report

Q A
BC Break yes
Version 2.11

Summary

findBy with more than 2100 parameters generates an error in SQL Server due to its limitation on the number of parameters in an IN clause.

Current behavior

Error:
An exception occurred while executing a query: SQLSTATE[IMSSP]: Tried to bind parameter number 2101. SQL Server supports a maximum of 2100 parameters.

How to reproduce

On MSSQL

private EntityRepository $doctrineRepository;
$ids = [1,2,... ,2101];
$this->doctrineRepository->findBy(['id' => $ids ])

Expected behavior

Doctrine should handle cases where the number of parameters exceeds 2100.

@derrabus
Copy link
Member

How should the ORM work around this limitation?

@bsauvajon26
Copy link
Author

In our case: Split the query into multiple smaller queries, each with a maximum of 2100 parameters, and then aggregate the results.

But it may be complicated if there are more than one condition

@derrabus
Copy link
Member

… and close to impossible if you want to sort the result.

@derrabus
Copy link
Member

tbh, my favorite solution would be to close this as a won't fix. Maybe we can document the limitation and possible workarounds.

@greg0ire
Copy link
Member

| Q | A
|------------ | ------
| BC Break | yes
| Version | 2.11

Is this accurate? Did you just upgrade from 2.10 (or lower?) to 2.11 and hit this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants