Skip to content

Commit

Permalink
[#14584] - Added more types for the casting
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Dec 7, 2019
1 parent 8bad37c commit 52076b2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions phalcon/Mvc/Model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
// Change the dirty state to persistent
instance->setDirtyState(dirtyState);

/**
* Assign the data in the model
*/
for key, value in data {
// Only string keys in the data are valid
if typeof key !== "string" {
Expand Down Expand Up @@ -790,12 +793,16 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,

if value != "" && value !== null {
switch attribute[1] {
case Column::TYPE_BIGINTEGER:
case Column::TYPE_INTEGER:
case Column::TYPE_MEDIUMINTEGER:
case Column::TYPE_SMALLINTEGER:
case Column::TYPE_TINYINTEGER:
let castValue = intval(value, 10);
break;

case Column::TYPE_DOUBLE:
case Column::TYPE_DECIMAL:
case Column::TYPE_DOUBLE:
case Column::TYPE_FLOAT:
let castValue = doubleval(value);
break;
Expand All @@ -810,11 +817,15 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
}
} else {
switch attribute[1] {
case Column::TYPE_INTEGER:
case Column::TYPE_DOUBLE:
case Column::TYPE_BIGINTEGER:
case Column::TYPE_BOOLEAN:
case Column::TYPE_DECIMAL:
case Column::TYPE_DOUBLE:
case Column::TYPE_FLOAT:
case Column::TYPE_BOOLEAN:
case Column::TYPE_INTEGER:
case Column::TYPE_MEDIUMINTEGER:
case Column::TYPE_SMALLINTEGER:
case Column::TYPE_TINYINTEGER:
let castValue = null;
break;

Expand Down

0 comments on commit 52076b2

Please sign in to comment.