mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
SQLFilters are too locked down #6382
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 @oojacoboo on GitHub (Jan 13, 2020).
I created a pull request for an issue with SQLFilters related to the EntityManager, which is a dependency of the
SQLFilterclass but not exposed to child classes. However, I'm now faced with another issue related to SQLFilters that is more of the result of the same mentality that continues to haunt me with Doctrine.I'm certain this won't be met with open arms, because it's honestly just an disagreement with approach. But everything in Doctrine makes the assumption that developers using the library do not know what they're doing and do not need to extend it freely.
Situation:
I need to create an
SQLFilterthat reads annotations. Due to performance implications, I need to be able to used theCachedReader, as the annotations are already cached, and being that it's a filter which is applied on every query, using the standardAnnotationReaderwithout cache, isn't really sufficient. The performance hit is real.Problem:
Filters are locked down tight. You do not have access to the constructor and the filters, after being constructed, are not easily accessible. So, adding dependencies is a bit more of a challenge, and nasty, and prone to future BC breaks.
That is really nasty. It shouldn't be. I also should be able to write filters and use this lib as needed for proper implementation. Without SQLFitlers, this ORM simply wouldn't work. We need proper multi-tenancy support, which needs to be applied via Filters for relational entity access, etc. Annotations are the most logical way of handling this.
I'm requesting that SQLFilter design be re-visited. I'd also encourage a bit of a change in mentality towards locking down the library, but I realize that's just a difference in opinion and most likely unwelcomed.
@SenseException commented on GitHub (Jan 16, 2020):
Hi @oojacoboo, can you please evaluate in which direction you want to see the filters go? Maybe you can provide a code-example for showing what you describe.
Also: Can you please explain in an code example what your custom filter is doing? For now I understand that you'e unhappy with the lack of using a constructor.
@oojacoboo commented on GitHub (Jan 16, 2020):
Hey @SenseException. I've published the extension. Maybe it'd be helpful to have a look over the Filter class there.
https://github.com/rentpost/doctrine-multi-tenancy
As you can see, there are a number of hacks. Efforts to eliminate all those hacks would be my recommendation.
@kgilden commented on GitHub (Feb 14, 2022):
I think "too locked down" might be a bit too harsh, but I'd also like to add to this a couple of observations.
Configuration::addFilter().FilterCollection::getFilter().So in a nutshell, it would already make using filters really powerful, if we could pass instances instead of class names and if they would stay instantiated through the enable-disable cycle. I'm sure there are really good reasons for doing it the current way, so maybe someone more knowledgeable could elaborate a bit.
/cc @SenseException
@greg0ire commented on GitHub (Feb 14, 2022):
This seems related: https://github.com/doctrine/orm/pull/434