DDC-1386: getPartialReference() will result in data loss if default values are used #1738

Closed
opened 2026-01-22 13:23:48 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 21, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user stefanklug:

If a entity uses default values e.g.

class User {
    private $id;
    private $name = "unnamed";
}

a reference returned from EntityManager::getPartialReference() will automatically result in a scheduled update for this entity (and all fields with default values), because the EM expects the fields of the entity to be empty. This results in resetting all data inside the database to the default values when doing an $em->flush().

Regards Stefan

Originally created by @doctrinebot on GitHub (Sep 21, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user stefanklug: If a entity uses default values e.g. ``` class User { private $id; private $name = "unnamed"; } ``` a reference returned from EntityManager::getPartialReference() will automatically result in a scheduled update for this entity (and all fields with default values), because the EM expects the fields of the entity to be empty. This results in resetting all data inside the database to the default values when doing an $em->flush(). Regards Stefan
admin added the Bug label 2026-01-22 13:23:48 +01:00
admin closed this issue 2026-01-22 13:23:49 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 21, 2011):

@doctrinebot commented on GitHub (Sep 21, 2011): - depends on [DDC-209: Add the notion of read-only entities](http://www.doctrine-project.org/jira/browse/DDC-209)
Author
Owner

@doctrinebot commented on GitHub (Oct 15, 2011):

Comment created by @beberlei:

Verified, have a fix for this already but its rather tricky with how far i want to push this.

@doctrinebot commented on GitHub (Oct 15, 2011): Comment created by @beberlei: Verified, have a fix for this already but its rather tricky with how far i want to push this.
Author
Owner

@doctrinebot commented on GitHub (Oct 15, 2011):

Comment created by @beberlei:

I committed a fix into master and 2.1.x 3801e0c230

This could somewhat be considered a BC. But i doubt people use partial objects to update the fields they omitted.

@doctrinebot commented on GitHub (Oct 15, 2011): Comment created by @beberlei: I committed a fix into master and 2.1.x https://github.com/doctrine/doctrine2/commit/3801e0c230b5bf4060ee72800a270340ffee2355 This could somewhat be considered a BC. But i doubt people use partial objects to update the fields they omitted.
Author
Owner

@doctrinebot commented on GitHub (Oct 15, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 15, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1738