fix: Entity::hasChanged() is unreliable for casts
~~Need to rebase after merging #6285~~
Description Fixes #5905
- fix
hasChanged()is unreliable for casts - ~~fix
hasChanged()returns wrong result to mapped property~~ --> #6285
Checklist:
- [x] Securely signed commits
- [x] Component(s) with PHPDoc blocks, only if necessary or adds value
- [ ] Unit testing, with >80% coverage
- [ ] User guide updated
- [x] Conforms to style guide
Addendum, since most of the discussion so far has been about typing (e.g. 35 versus '35')... Entity is mildly tied to Model (not BaseModel) in that the hasChanged() methods affect database interactions. Since Model is inherently SQL-based there is an impulse to assume Entity is a representation of SQL data but I would argue that this is a big violation.
My guess is this assumption is what is mostly behind the "35 age" example we've been using: since the SQL column data type cannot change we are safe to manipulate types in developer logic. However as soon as the data source becomes collection, array store, NoSQL database, JSON file, etc... that assumption will wreak havoc.
@kenjis What's the update here?
Just rebased to resolve conflicts.
Since Entity is designed to have "raw data" (values retrieved from a database), it is difficult to determine if the value as PHP has changed. Raw data can change depending on the database driver and/or configuration.
@MGatner I sent a brand new PR #7995