Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-RC1
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      In my previous Bug Report DDC-871 I'm using a separate table for versioning copies. However, if one wishes to keep all versions in a single table, this causes some headaches, since the field with @version can't be set by the developer (i.e. Doctrine2 does magic here).

      I'll try to describe it with some meta code.

      Let's say you have the class SingleTable, which has a property version marked with @version and @id, and also a property id marked with @id. I know this isn't the preferred way since it's a composite primary key, but in theory it would work. I'm managing the ID of the object myself, which works without a problem.

      The problem is that once a field is marked with @version, it isn't set during an insert operation. Doctrine2 relies on the field's default value. This causes the following problems:

      • You can't start with an object version higher than 1.
      • If you wish to insert an older version (which is possible with my composite primary key example), you can't simply set the version - Doctrine2 does it's own magic, which fails at this point.

      No matter if there will be a change to the @version behavior or not, it should be documented a bit better in the documentation. Once I know if it will be changed or not, I can contribute additional documentation for this.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Yes @Version and @Id are not allowed. This should just throw an exception.

        Show
        Benjamin Eberlei added a comment - Yes @Version and @Id are not allowed. This should just throw an exception.
        Hide
        Timo A. Hummel added a comment -

        As I'm already working on some documentation things, I will add this to the documentation and maybe also add some code to throw an Exception.

        Show
        Timo A. Hummel added a comment - As I'm already working on some documentation things, I will add this to the documentation and maybe also add some code to throw an Exception.
        Hide
        Timo A. Hummel added a comment -

        Just created a pull request for this (I added the bugfix + testcase), feel free to close after pull.

        Show
        Timo A. Hummel added a comment - Just created a pull request for this (I added the bugfix + testcase), feel free to close after pull.
        Hide
        Benjamin Eberlei added a comment -

        Implemented exception on this wrong usage.

        Show
        Benjamin Eberlei added a comment - Implemented exception on this wrong usage.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Timo A. Hummel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: