DBAL-858: Workaround for Oracle's limit in IN clause items#2699
DBAL-858: Workaround for Oracle's limit in IN clause items#2699tomaszmadeyski wants to merge 1 commit intodoctrine:masterfrom tomaszmadeyski:dbal-858
Conversation
|
In my understanding, Oracle enforces the limit on the number of parameters in order to prevent huge queries and too many bound variables. As long as these values are not taken from the input, the query above can be rewritten using subquery. Otherwise, a temporary table can be used. I don't think the DBAL should workaround this limitation. |
And especially not with hacks/workarounds. If there were a proper solution, then we could use it, but this really just needs to be escalated to the underlying driver's maintainer. |
That's exact issue I'm trying to solve. Using temporary table means writing a lot of boilerplate code and it's a hassle
This is a port of solution for .NET's Entity Framework in their Oracle's driver, it is done in DBAL layer and I think it is very convenient http://blog.devart.com/entity-framework-sql-generation-enhancements-for-in-clause.html (see
Do you mean oci8 driver's maintainer? If so this is not an issue of a driver, it is a feature/limitation of a DB engine itself and I don't think there's any chance Oracle will change this |
Well aware of it, but this really shouldn't lead to this massive amount of complication for an edge case. The fact that a tool has an imposed limitation doesn't mean that everyone else should work hard to provide a messy workaround for it: it should be fixed at the source of the problem or not at all, sorry :-\ If anyone knows Oracle devs that can influence the decisions there (I doubt it, since it's corporate world, which is basically Vogon poetry ^ 2), then please poke them and ask what the correct approach would be here. Adding complexity to the DBAL is something I'd not really want, as it already spawned massive amounts of headache for SQL Server (limit subquery mess). |
Oracle does not allow queries with more than 1000 elements in IN clause
Query:
SELECT ... WHERE foo IN (1,..., 1001)will result in
ORA-01795 maximum number of expressions in a list is 1000This PR introduces method to convert such queries from
SELECT ... WHERE foo IN (1,..., 1001)to
SELECT ... WHERE (foo IN (1,..., 1000) OR foo IN (1001))and does this conversion before parsing query
It fixes #2095