Let XML driver treat <id> field attributes same as regular <field> tag#10813
Conversation
greg0ire
left a comment
There was a problem hiding this comment.
Please run vendor/bin/phpcbf and amend your commit.
| if (isset($idElement->options)) { | ||
| $mapping['options'] = $this->parseOptions($idElement->options->children()); | ||
| } | ||
| $mapping = $this->columnToArray($idElement); |
There was a problem hiding this comment.
I am not sure this is correct. Before columnToArray() was introduced, the id mapping evaluation looked like this:
orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Lines 292 to 302 in 4df3c75
On the other hand, the field mapping evaluation looked like this:
orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Lines 231 to 269 in 4df3c75
That being said, you mention the other drivers already do what you describe, so I guess we could do this for the sake of consistency.
There was a problem hiding this comment.
As you said XmlDriver lack of consistency in comparison to other drivers. With annotations/attributes, we declare a standard field and only mark it as ID.
@Id()
@Column(...)In XML, we must declare the whole field as a different tag and it should accept all standard field parameters.
@greg0ire code style issues fixed |
|
Thanks @Greg0 ! |
According to other drivers,
idfield, should be treated as regular field and marked as anid.In XML driver for id-field, there was code duplication in parsing field attributes. However, it was not updated at all for a while, so regular field growth with new attributes (e.g.
enum-type) but id-field not.Similar to other drivers, id-field attributes are parsed by same method in regular-field and enriched by
idflag.For example, without that fix, it is impossible to use XML driver and enum field as part of composite primary key.
Let me know if you need more details for that change.