Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurigag committed Mar 9, 2017
1 parent 23e173e commit 98741e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
- Fixed `Phalcon\Mvc\Model::getChangedFields` to correct detect changes from NULL to Zero [#12628](https://github.com/phalcon/cphalcon/issues/12628)
- Fixed `Phalcon\Mvc\Model` to create/refresh snapshot after create/update/refresh operation [#11007](https://github.com/phalcon/cphalcon/issues/11007), [#11818](https://github.com/phalcon/cphalcon/issues/11818), [#11424](https://github.com/phalcon/cphalcon/issues/11424)
- Fixed `Phalcon\Mvc\Model::validate` to correctly set code message [#12645](https://github.com/phalcon/cphalcon/issues/12645)
- Added the value of the object intanceof Interface to `Phalcon\AcMl\Adapter\Memory`
- Added the value of the object intanceof Interface to `Phalcon\Acl\Adapter\Memory`
- Fixed `Phalcon\Mvc\Model` to correctly add error when try to save empty string value to not null and not default column [#12688](https://github.com/phalcon/cphalcon/issues/12688)

# [3.0.4](https://github.com/phalcon/cphalcon/releases/tag/v3.0.4) (2017-02-20)
- Fixed Isnull check is not correct when the model field defaults to an empty string. [#12507](https://github.com/phalcon/cphalcon/issues/12507)
Expand Down
2 changes: 1 addition & 1 deletion phalcon/mvc/model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
let isNull = true;
}
} else {
if value === null || (value === "" && value !== defaultValues[field]) {
if value === null || (value === "" && (!isset defaultValues[field] || value !== defaultValues[field])) {
let isNull = true;
}
}
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/Mvc/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Phalcon\Test\Unit\Mvc;

use DateTime;
use Helper\ModelTrait;
use Phalcon\Mvc\Model\Message;
use Phalcon\Test\Models\Users;
Expand Down Expand Up @@ -646,4 +647,28 @@ function () {
}
);
}

/**
* Tests empty string value on not null
*
* @issue 12688
* @author Wojciech Ślawski <[email protected]>
* @since 2017-03-09
*/
public function testIssue12688()
{
$this->specify(
'Issue 12688 is happening',
function () {
$robots = new Robots();
$robots->name = '';
$robots->save(
[
'datetime' => (new DateTime())->format('Y-m-d'),
'text' => 'text',
]
);
}
);
}
}

0 comments on commit 98741e8

Please sign in to comment.