Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Properly generate default value from yml & xml mapping#1327

Closed
j0k3r wants to merge 1 commit into
doctrine:masterfrom
j0k3r:entity-default-value
Closed

Properly generate default value from yml & xml mapping#1327
j0k3r wants to merge 1 commit into
doctrine:masterfrom
j0k3r:entity-default-value

Conversation

@j0k3r
Copy link
Copy Markdown
Contributor

@j0k3r j0k3r commented Mar 10, 2015

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 :

@doctrinebot
Copy link
Copy Markdown

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3608

We use Jira to track the state of pull requests and the versions they got
included in.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add assertions for these changes? Or was the original assertion wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation, the original assertion was wrong

@Ocramius Ocramius self-assigned this Mar 16, 2015
Ocramius added a commit that referenced this pull request Mar 17, 2015
@Ocramius Ocramius closed this in 8f0b339 Mar 17, 2015
@Ocramius
Copy link
Copy Markdown
Member

Merged, thanks!

master: 8f0b339
2.4: 9dfa20d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants