开发者

Symfony: loading fixture data with required fields empty?

I noticed that propel loads the fixture data into the database, even though we didnt specify some of the required fields of the table inside the .yml files.

What are the reasons behind this? Easier development, etc.?

Schema:

  jobeet_job:
    id:           ~
    category_id:  { type: integer, foreignTable: jobeet_category, foreignReference: id, required: true }
    type:         { type: varchar(255) }
    company:      { type: varchar(255), required: true }
    logo:         { type: varchar(255) }
    url:          { type: varchar(255) }
    position:     { type: varchar(255), required: true }
    location:     { type: varchar(255), required: true }
    description:  { type: longvarchar(255), required: true }
    how_to_apply: { type: longvarchar(255), required: true }
    token:        { type: varchar(255), required: true, index: unique }
    is_public:    { type: boolean, required: true, default: 1 }
    is_activated: { type: boolean, required: true, default: 0 }
    email:        { type: varchar(255), required: true }
    expires_at:   { type: timestamp, required: true }
    created_at:   ~
    updated_at:   ~

So, expires_at is required: true.

Data:

  expired_job:
    category_id:  design
    company:      Extreme sensio
    position:     Web Designer
    location:     Paris, France
    description:  |
      Lorem ipsum dolor 开发者_如何学编程sit amet.
    how_to_apply: |
      Send your resume to fabien.potencier at sensio.com.
    is_public:    true
    is_activated: true
    token:        job_expired

So, nowhere is the expires_at field set.

Yet I am able to run

symfony propel:data load task.


This link http://dev.mysql.com/doc/refman/5.0/en/timestamp.html explains the defaults for the TIMESTAMP type in MySQL (im assuming your using MySQL).


In another question of yours you quote the save method of the JobeetJob class. You can see there that the expires_at gets set there unless set manually before - therefore filling the required field, so all is good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜