When Yii2 ActiveRecord save (), the non-date type field is set to Expression verification failure, is there a solution within the framework?

$model = new Test();
$model->uuid   = new Expression("UUID()");
$model->create = new Expression("NOW()");
if($model->save() === false)
{
    echo(json_encode($model->getErrors()));exit;
}
else
    echo("saved");

the output is shown as:

{"uuid ":["uuid must be a string."]}

the result of the check is that the validation rules automatically generated by the Yii2 framework

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [["create"], "safe"],
            [["uuid"], "string", "max" => 64],
            [["uuid"], "unique"],
        ];
    }
  • date type field is safe, only verify whether it exists, and do not do specific verification
  • The
  • string type field is verified by string, and it is found that Expression has reported an error
  • .

non-framework solutions include inheriting ActiveRecord processing to validate related code and skipping Expression

Is there any ready-made way to solve this problem within the

framework?

someone must have encountered a similar problem, and there should be a solution within the framework.

Feb.27,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37b3f-34480.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37b3f-34480.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?