You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was a similar discussion before, and now it seems that it can be avoided by setting the default value (DEFAULT '').
I think there should be a distinction between Null and '', and I think that's the way SQL thinks, so it should work without a default value.
However, it is not a big problem because there is no problem in terms of reality.
However, if you try to set the column msg TEXT NOT NULL DEFAULT '' to empty, the automatic null check will result in an error.
In such cases, the default value of metadata is "''", and '' is not considered to match the default.
I am using mariaDB 10.8.3, but when reading the table structure, it may not be '' if it is TEXT.
In older versions, default values could not be set for TEXT columns, but in 10.8.3 they can be set, and it seems to work without problems if SQL is sent directly.
There are several ways to avoid this, but \Phalcon\Mvc\Model::setup(array('notNullValidations' => false)); has too much impact and cannot be adopted.
public function beforeValidation()
{
if ($this->msg === '') {
$this->msg = new \Phalcon\Db\RawValue('""');
}
}
or
public function initialize()
{
$this->modelsMetaData->setEmptyStringAttributes($this, ['msg'=>true]);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
There was a similar discussion before, and now it seems that it can be avoided by setting the default value (
DEFAULT ''
).I think there should be a distinction between Null and
''
, and I think that's the way SQL thinks, so it should work without a default value.However, it is not a big problem because there is no problem in terms of reality.
However, if you try to set the column
msg TEXT NOT NULL DEFAULT ''
to empty, the automatic null check will result in an error.In such cases, the default value of metadata is
"''"
, and''
is not considered to match the default.I am using mariaDB 10.8.3, but when reading the table structure, it may not be
''
if it is TEXT.In older versions, default values could not be set for TEXT columns, but in 10.8.3 they can be set, and it seems to work without problems if SQL is sent directly.
There are several ways to avoid this, but
\Phalcon\Mvc\Model::setup(array('notNullValidations' => false));
has too much impact and cannot be adopted.or
Neither seems to be an error.
Which one do you prefer?
Beta Was this translation helpful? Give feedback.
All reactions