DDC-3608: [GH-1327] Properly generate default value from yml & xml mapping #4433

Closed
opened 2026-01-22 14:41:31 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 10, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of j0k3r:

Url: https://github.com/doctrine/doctrine2/pull/1327

Message:

Yaml & Xml mapping which define default value for a field aren't properly generated in the entity class by the EntityGenerator.

This is how the documentation says to define a default value in xml:

<field name="login_count" type="integer" nullable="false">
    <options>
        <option name="default">0</option>
    </options>
</field>

and in yml:

    loginCount:
      type: integer
      column: login_count
      nullable: false
      options:
        default: 0

Both generates this field mapping (aka $fieldMapping):

array(5) {
  'fieldName' =>
  string(11) "login_count"
  'type' =>
  string(7) "integer"
  'nullable' =>
  bool(false)
  'options' =>
  array(1) {
    'default' =>
    string(1) "0"
  }
  'columnName' =>
  string(11) "login_count"
}

But the EntityGenerator check the default value in the wrong place, in $fieldMapping['default'] instead of $fieldMapping['options']['default'].

This is related to :

Originally created by @doctrinebot on GitHub (Mar 10, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of j0k3r: Url: https://github.com/doctrine/doctrine2/pull/1327 Message: Yaml & Xml mapping which define default value for a field aren't properly generated in the entity class by the `EntityGenerator`. This is how the documentation says to define a default value in [xml](http://doctrine-orm.readthedocs.org/en/latest/reference/xml-mapping.html): ``` xml <field name="login_count" type="integer" nullable="false"> <options> <option name="default">0</option> </options> </field> ``` and in [yml](http://doctrine-orm.readthedocs.org/en/latest/reference/yaml-mapping.html): ``` yaml loginCount: type: integer column: login_count nullable: false options: default: 0 ``` Both generates this field mapping (aka `$fieldMapping`): ``` php array(5) { 'fieldName' => string(11) "login_count" 'type' => string(7) "integer" 'nullable' => bool(false) 'options' => array(1) { 'default' => string(1) "0" } 'columnName' => string(11) "login_count" } ``` But the `EntityGenerator` check the default value in the wrong place, in `$fieldMapping['default']` instead of `$fieldMapping['options']['default']`. This is related to : - this JIRA ticket: http://www.doctrine-project.org/jira/browse/[DDC-2809](http://www.doctrine-project.org/jira/browse/DDC-2809) - this PR https://github.com/doctrine/doctrine2/pull/853
admin added the Bug label 2026-01-22 14:41:31 +01:00
admin closed this issue 2026-01-22 14:41:34 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 10, 2015):

@doctrinebot commented on GitHub (Mar 10, 2015): - is referenced by [DDC-2809: [GH-853] Fix for PHP entity default values generated by EntityGenerator](http://www.doctrine-project.org/jira/browse/DDC-2809)
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1327] was labeled:
https://github.com/doctrine/doctrine2/pull/1327

@doctrinebot commented on GitHub (Mar 16, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1327] was labeled: https://github.com/doctrine/doctrine2/pull/1327
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1327] was assigned:
https://github.com/doctrine/doctrine2/pull/1327

@doctrinebot commented on GitHub (Mar 16, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1327] was assigned: https://github.com/doctrine/doctrine2/pull/1327
Author
Owner

@doctrinebot commented on GitHub (Mar 17, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1327] was closed:
https://github.com/doctrine/doctrine2/pull/1327

@doctrinebot commented on GitHub (Mar 17, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1327] was closed: https://github.com/doctrine/doctrine2/pull/1327
Author
Owner

@doctrinebot commented on GitHub (Mar 17, 2015):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 17, 2015): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4433