Affects Version/s: None
Fix Version/s: 2.0-RC1
Security Level: All
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.