-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DDC-551: Consider adding ability to specify additional join conditions on a @JoinTable / @JoinColumn #5059
Comments
|
Comment created by yaroslav: Would be great to get this functionality |
Comment created by @beberlei: Assigned to asm89 |
Comment created by @beberlei: Scheduled for 2.2 |
Comment created by @asm89: I've been working on this ticket over here: Latest thing I added was the state of the collection of filters, because this is needed for parsing (and sometimes not parsing) the queries to generate SQL. I'd like some feedback about the state keeping. More information at the commit: At this point the EntityManager keeps track of this state, but maybe it would be nice to have a separate FilterCollection keep track of the state/hashes etc? |
Comment created by @beberlei: Implemented |
Issue was closed with resolution "Fixed" |
Comment created by darkangel: Alex mentioned on IRC that filters do not provide the functionality that the OP requires, so this issue should really re-opened, unless I'm missing something? |
@asm89 I don't see how this resolves the original issue. It requires adding conditions on the related join and filters don't seem to have access to that kind of information. |
I don't think the original issue is resolved. By looking at the source code, there is simply no hook that allows us to add conditions to the first |
@benface You are actually mostly correct here, it does not. But, with annotations hooked into your filters, you can add your own custom decorators and then add these in the where clause. It's a nasty hack IMO and support for custom/additional join conditions should be supported. We just hit a similar issue with many:one relationship and soft-delete (actually archive, similar idea) on the one side of the relationship. If we had the ability to define an additional join condition, we could simply check that |
Jira issue originally created by user mjh_ca:
Per discussion with beberlei and romanb in #doctrine-dev yesterday, opening this ticket as a "feature request" to support migrating legacy schemas with a special many-to-many mapping to Doctrine.
Consider the following schema:
There is a Many-To-Many relationship between each of the posts and videos table (via the content_category_association table) to the categories table. The difference from a standard many-to-many relationship is there is an extra column in the association table (content_type) which must be included in the join condition to return correct results. Since both the videos and posts table have their own autonumber primary keys, a join against the association table must include an extra condition (i.e. INNER JOIN ... ON ... AND content_category_association.content_type = 'posts').
Perhaps you could allow passing of additional properties to @jointable / joinColumns to specify the additional join condition .. i.e.:
Certainly this schema is not ideal from a pure OO perspective. Class inheritance with a discriminator column may have been a better way to do this, thereby allowing a globally unique "content_id" for all types of content, negating the need for the extra column in the association table. However, it would nonetheless be helpful to have this additional capability within Doctrine to avoid having to re-factor such a legacy schema.
The text was updated successfully, but these errors were encountered: