-
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
ReadOnly and changeTrackingPolicy could not be set on embeddable #6711
Comments
Embeddable is not tracked on its own, but as part of its parent entity, so
I don't think anything should be done for the lifecycle of embeddable
objects, as they don't have their own lifecycle at all.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
…On Wed, Sep 20, 2017 at 1:14 PM, Sergey ***@***.***> wrote:
Pretty much what the subject says.
While I realize this is something that unlikely gets fixed, partially
because this is 0.5% case, partially because readOnly is going to be
removed in 3.x
<#5728 (comment)>,
I'd like to get some feedback nevertheless.
The use case is the date range embeddable (DateTime start, DateTime end, DateTimeZone
tz)
Because the DateTime objects are not constructed properly(with the proper
timezone) upon loading from database, they need to be re-constructed
(meaning properties of embeddable get re-set) which, in turn, marks the
embeddable as dirty in UoW.
Because there's no way to unmark the object as dirty in UoW (or I didn't
find it) and readOnly/changeTrackingPolicy=notify are not supported by
embeddables - there doesn't seem to be a way to workaround this problem. (a
custom doctrine type would not suffice as well because it's only 1-1
mapping and doesn't allow to map a single object into multiple table
columns, and vice versa)
Is there some other workaround I've overlooked?
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6711>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakD3FVlhTFs7RLumGfbc9OKjC0Hbzks5skPOigaJpZM4PdtgK>
.
|
@sserbin I believe you can hide this behind the Embeddables state by adding unmapped properties: /** @ORM\Embeddable */
class Date
{
/** @ORM\Column(type="string") */
private $date;
/** @ORM\Column(type="string") */
private $tz;
/** not mapped **/
private $datetime;
public function getDateTime()
{
if ($this->datetime === null) {
$this->datetime = new DateTime($this->date, new DateTimeZone($this->tz));
}
return $this->datetime;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty much what the subject says.
While I realize this is something that unlikely gets fixed, partially because this is 0.05% case, partially because readOnly is going to be removed in 3.x, I'd like to get some feedback nevertheless.
The use case is the date range embeddable (
DateTime start
,DateTime end
,DateTimeZone tz
)Because the
DateTime
objects are not constructed properly(with the proper timezone) upon loading from database, they need to be re-constructed (meaning properties of embeddable get re-set) which, in turn, marks the embeddable as dirty in UoW.Because there's no way to unmark the object as dirty in UoW (or I didn't find it) and
readOnly
/changeTrackingPolicy=notify
are not supported by embeddables - there doesn't seem to be a way to workaround this problem. (a custom doctrine type would not suffice as well because it's only 1-1 mapping and doesn't allow to map a single object into multiple table columns, and vice versa)Is there some other workaround I've overlooked?
Thanks
The text was updated successfully, but these errors were encountered: