Fix: not null not checked with type

This commit is contained in:
sheychen 2018-05-01 16:45:41 +02:00
parent acd024998b
commit d49baac317
1 changed files with 3 additions and 3 deletions

View File

@ -139,6 +139,9 @@ class Model{
protected static function convertField($data, $field){
$options = static::getOptions($field);
if(is_null($data) && isset($options['not_null']) && $options['not_null'] == true)
throw new DatabaseException('Can\'t set null to NOT NULL field : '.$field);
if(isset($options['type'])){
switch(strtolower($options['type'])){
case 'int':
@ -157,9 +160,6 @@ class Model{
}
}
if(is_null($data) && isset($options['not_null']) && $options['not_null'] == true)
throw new DatabaseException('Can\'t set null to NOT NULL field : '.$field);
return $data;
}