Skip to content

Commit

Permalink
Merge pull request #16038 from LlamaDuckGoose/v5/bugfix/RawValue-no-l…
Browse files Browse the repository at this point in the history
…onger-supports-mysql-functions

[BUG]: RawValue no longer supports mysql functions
  • Loading branch information
niden authored Aug 5, 2022
2 parents e6d527c + 8af9dc3 commit 40ff5c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `Phalcon\Cli\RouterInterface::getMatchedRoute()`
- `Phalcon\Mvc\Router::getMatchedRoute()`
- `Phalcon\Mvc\RouterInterface::getMatchedRoute()` to return `RouterInterface` or `null` [#16030](https://github.com/phalcon/cphalcon/issues/16030)
- Fixed `Phalcon\Mvc\Model::doLowUpdate()` prevent RawValue getting overwritten [#16037](https://github.com/phalcon/cphalcon/issues/16037)

# [5.0.0rc3](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC3) (2022-07-12)

Expand Down
15 changes: 9 additions & 6 deletions phalcon/Mvc/Model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3919,7 +3919,8 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
var automaticAttributes, attributeField, bindSkip, bindDataTypes,
bindType, bindTypes, columnMap, dataType, dataTypes, field, fields,
manager, nonPrimary, newSnapshot, success, primaryKeys, snapshot,
snapshotValue, uniqueKey, uniqueParams, uniqueTypes, value, values;
snapshotValue, uniqueKey, uniqueParams, uniqueTypes, value, values,
updateValue;
bool changed, useDynamicUpdate;

let bindSkip = Column::BIND_SKIP,
Expand Down Expand Up @@ -4027,19 +4028,21 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
if is_object(snapshotValue) && snapshotValue instanceof RawValue {
let snapshotValue = snapshotValue->getValue();
}

let updateValue = value;
if is_object(value) && value instanceof RawValue {
let value = value->getValue();
let updateValue = value->getValue();
}

switch dataType {

case Column::TYPE_BOOLEAN:
let changed = (bool) snapshotValue !== (bool) value;
let changed = (bool) snapshotValue !== (bool) updateValue;
break;

case Column::TYPE_DECIMAL:
case Column::TYPE_FLOAT:
let changed = floatval(snapshotValue) !== floatval(value);
let changed = floatval(snapshotValue) !== floatval(updateValue);
break;

case Column::TYPE_INTEGER:
Expand All @@ -4050,14 +4053,14 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,
case Column::TYPE_TEXT:
case Column::TYPE_VARCHAR:
case Column::TYPE_BIGINTEGER:
let changed = (string) snapshotValue !== (string) value;
let changed = (string) snapshotValue !== (string) updateValue;
break;

/**
* Any other type is not really supported...
*/
default:
let changed = value != snapshotValue;
let changed = updateValue != snapshotValue;
}
}
}
Expand Down

0 comments on commit 40ff5c2

Please sign in to comment.