0

我正在尝试以这种方式为 yml 文件上的 profile_percentage 字段设置默认值

...
....
profilePercentage:
            type: float
            column: profile_percentage
            nullable: false
            options:
                comment: Profile surveys completed percentage
                default: 0

为了避免手动设置字段

$client->setProfilePercentage(0.0); 

但是通过这种配置,我会收到以下消息:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'profile_percentage' cannot be null
4

1 回答 1

0

默认值不是 100% 可移植的,在学说中最安全的方法是在实体构造函数中。

于 2018-08-13T12:11:00.603 回答