mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-280: UnitOfWork changeSet population should take advantage of Comparable technique #347
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 (Jan 27, 2010).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user @guilhermeblanco:
Currently our UnitOfWork computes the changeset by checking actual instances of Objects.
While this is ok when you do new object assignments, it just bypass same instances of same object, since the hash is the same.
A user on IRC (post-o-matic) has a quite complex object logic that he would like to avoid clone and even instantiate another class.
I agree with him that cloning is not the ideal technique, mainly because the changeset would always compute the object (since then hashs would be different).
He implemented this datatype:
I was thinking in a possible alternative and it came up to me the same basic idea we have with operators overloading OR Comparable interface of Java. I know in Java it supports way more things, but at least for this situation (as a start point) it would make developer's life easier.
Basic idea is to have an interface in Doctrine\Common:
And update our UnitOfWork to take advantage of it:
In this user's usecase, it'd require him to update the EffortGraph class and implement Comparable interface.
For his specific situation, he'd need to store original value and updated value, just like we do internally in UnitOfWork for Entities.
@doctrinebot commented on GitHub (May 19, 2010):
Comment created by @guilhermeblanco:
What's the final status of this?
IMHO this should be incorporated, since it adds a powerful support that users can take advantage in our Types.
Cheers,
@doctrinebot commented on GitHub (May 19, 2010):
Comment created by @guilhermeblanco:
You're the main guy that can give a final word in this subject.
I'm +1 for this
@doctrinebot commented on GitHub (Feb 4, 2011):
Comment created by rv4wd:
+1 for this...
if you have datetimes in a table and are using the DateTime object, you end up with useless update queries, if you persist an unchanged object...
@doctrinebot commented on GitHub (Feb 4, 2011):
Comment created by @beberlei:
That is not true.
@doctrinebot commented on GitHub (Feb 4, 2011):
Comment created by rv4wd:
Sorry, I wasn't clear.
It does not happen in all cases.
I have a simple object, that I save to the session. After merging it and flushing the entitiy manager, an update query is generated, which sets all the datetime fields of the object to their current value:
This code results in the expected SELECT query, which refreshes the item from DB, but it also results in an update query which sets the datetime of the object to the same value.
This query could be omitted, if I could use a comparable interface and a custom type for datetimes, which implement it.
@doctrinebot commented on GitHub (Feb 4, 2011):
Comment created by @beberlei:
This rather seems like a bug with the merging. Can you open up a new ticket describing this? Thank you
@AlexeyKosov commented on GitHub (Jul 26, 2017):
Related to #5542
Any advance on this?
@Ocramius commented on GitHub (Aug 3, 2017):
This is a
won't fixuntil we do data comparison post DBAL type conversion, and that's not going to happen for now.Closing.