[PR #1327] Properly generate default value from yml & xml mapping #9381

Closed
opened 2026-01-22 16:04:09 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/1327

State: closed
Merged: No


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 :

**Original Pull Request:** https://github.com/doctrine/orm/pull/1327 **State:** closed **Merged:** No --- 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 - this PR https://github.com/doctrine/doctrine2/pull/853
admin added the pull-request label 2026-01-22 16:04:09 +01:00
admin closed this issue 2026-01-22 16:04:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9381