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

[BUG]: RawValue no longer supports mysql functions #16038

Merged
merged 2 commits into from
Aug 5, 2022
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
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