mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1400: joining and selecting associated collection, which is using indexBy, to a query is triggering UPDATE queries for each collection element which were joined. #1751
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 @doctrinebot on GitHub (Sep 30, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user hypno:
if i $em->flush() now it will execute lots of update queries like:
UPDATE userstate SET article_id = ? WHERE user_id = ? AND article_id = ?
@doctrinebot commented on GitHub (Oct 15, 2011):
Comment created by @beberlei:
I think your mapping is wrong. You cannot map an @Id + @ManyToOne and then remap the same column using @Column.
What exactly are the parameters to the query? How is it updating article_id ?
Is this even affected by "indexBy"? Can you remove them and try again?
@doctrinebot commented on GitHub (Oct 17, 2011):
Comment created by hypno:
I have to use @Id + $ManyToOne and @Column on the same database field because indexBy only supports normal @Columns as key. We have used this workaround numerous times in our system without any issues.
And it seems that this is not causing the updates. Here is another example:
UPDATE article_text SET article_id = 1 WHERE locale = 'en' AND article_id = 1
UPDATE article_text SET article_id = 2 WHERE locale = 'en' AND article_id = 2
UPDATE article_text SET article_id = 3 WHERE locale = 'en' AND article_id = 3
UPDATE article_text SET article_id = 4 WHERE locale = 'en' AND article_id = 4
UPDATE article_text SET article_id = 5 WHERE locale = 'en' AND article_id = 5
.......
it does it one per article for all articles in result.
If i remove the indexBy annotation the updates disappear. Extra lazy loading has no effect on this bug.
@doctrinebot commented on GitHub (Nov 19, 2011):
Comment created by @beberlei:
Attached is a working testcase with your example code.
Can you please verify that it follows your example exactly and try to make it generate those UPDATEs?
@doctrinebot commented on GitHub (Jan 2, 2012):
Comment created by @beberlei:
This is fixed in 2.1.3, it was a bug until 2.1.2
@doctrinebot commented on GitHub (Jan 2, 2012):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/f49004b43765c39a1733