Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1386

getPartialReference() will result in data loss if default values are used

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.1.3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      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

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

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

          Show
          Benjamin Eberlei added a comment - Verified, have a fix for this already but its rather tricky with how far i want to push this.
          Hide
          Benjamin Eberlei added a comment -

          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.

          Show
          Benjamin Eberlei added a comment - 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.

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Stefan Klug
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: