Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Support for default attribute in yaml mappings. #311

Merged
merged 1 commit into from
Mar 29, 2012

Conversation

benlumley
Copy link
Contributor

There's probably a very good reason you don't already do this... please let me know if there is!

The EntityGenerator supports writing a default value for a property/column when generating a class, but the yaml driver doesn't pick this up. This tiny change makes it work - you can do something like:

Acme\MyBundle\Entity\MyObject:
  type: entity
  table: my_object
  fields:
    active:
      type: boolean
      default: true

and you end up with..

/**
 * @var boolean $active
 */
private $active = true;

Similar change would also work for the other drivers I guess.

guilhermeblanco added a commit that referenced this pull request Mar 29, 2012
Proposal: Support for default attribute in yaml mappings.
@guilhermeblanco guilhermeblanco merged commit 290f8a7 into doctrine:master Mar 29, 2012
@stof
Copy link
Member

stof commented Mar 29, 2012

This should be implemented in XML too

@beberlei
Copy link
Member

@guilhermeblanco this also affects the SQL generation using the default value, we explictily removed this :-)

@benlumley
Copy link
Contributor Author

So will the change that's been merged be generating SQL with the default values? From the docs I can see you've decided against default values in SQL, which makes sense. I only wanted a way to get the defaults into the generated entity classes - which, to me at least, is very useful!

@beberlei
Copy link
Member

I agree, but for 2.3 we will probably get a completly new entity generator anyways, one that is actually extendable and such :)

beberlei added a commit that referenced this pull request Mar 30, 2012
@ihortymoshenko
Copy link

So is there a chance to determine the default value? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants