-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: add Model field casting #8243
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
kenjis
force-pushed
the
feat-model-type-casting
branch
17 times, most recently
from
November 29, 2023 05:18
922e64b
to
69606e2
Compare
kenjis
force-pushed
the
feat-model-type-casting
branch
6 times, most recently
from
December 2, 2023 08:19
f958080
to
6183c84
Compare
Implementation of this feature is complete. |
kenjis
added
database
Issues or pull requests that affect the database layer
bug
Verified issues on the current code behavior or pull requests that will fix them
labels
Dec 4, 2023
If you use casting in Model with Entity, do not use casting in Entity. Using both casting at the same time does not work. When using casting in Model, Entity has correct typed PHP values in the attributes. This behavior is completely different from the previous behavior. Do not expect the attributes hold raw data from database.
To add custom cast handlers.
The framework should not throw Error.
To fix PhpStorm errors.
kenjis
force-pushed
the
feat-model-type-casting
branch
from
February 12, 2024 23:53
a08a87d
to
94c7f08
Compare
Updated to use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
4.5
database
Issues or pull requests that affect the database layer
enhancement
PRs that improve existing functionalities
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Needs #8230, #8260, #8539Description
Entity is optional, and some devs do not want to use it.
See https://forum.codeigniter.com/showthread.php?tid=85956
This PR provides field type casting in Model so that all custom entities (or arrays) can use type casting.
This PR can solve #7177, #5905.
Model Field Casting
This casting only works when data comes from and goes to database.
To use this feature, add property
$casts
to a Model.Entity and this feature
Entity casting works at (1)(4), but this casting works at (2)(3).
If you use this feature with Entity, do not use casting in Entity.
Using both casting at the same time does not work.
When using casting in Model, Entity has correct typed PHP values in the attributes.
This behavior is completely different from the previous behavior.
Do not expect the attributes hold raw data from database.
TODO
Checklist: