Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #12688 #12691

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <jurigag@gmail.com>
* @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',
]
);
}
);
}
}