Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-859

Datetime object changeset computing

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.0-RC1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      php 5.3.2, windows

      Description

      The problem is with Datetime value on entity, if I dirrecly modify it, unitOfWork will not add it into change set
      // assume loaded entity through dql or repository:

      $entity->getStartDate()->modify("+ 1day");
      $em->persist($entity);
      $em->flush(); // no changes

      as far as I understand objects are compared through ($oldObject === $newObject) probably php takes spl_object_hash to do the comparison
      copying an object works as expected

        Activity

        Hide
        Benjamin Eberlei added a comment -

        This is expected behavior, DateTime objects are thought of as immutable value objects (php allowing them to be mutable is sort of a design mistake that even Derick sees now).

        Only changing the instance will change the value, otherwise the difference computation would be too difficult and would involve cloning the datetime (overhead).

        Show
        Benjamin Eberlei added a comment - This is expected behavior, DateTime objects are thought of as immutable value objects (php allowing them to be mutable is sort of a design mistake that even Derick sees now). Only changing the instance will change the value, otherwise the difference computation would be too difficult and would involve cloning the datetime (overhead).

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Gediminas Morkevicius
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: