-
Notifications
You must be signed in to change notification settings - Fork 280
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
If I set up the default values to some specific columns, these columns can not act the same expectation in partial bean mode. #754
Comments
Hi, I'm not sure I understand, everything seems to work as expected. Do you want to set defaults value only if you dispense a new bean, not when you load/find/etc an existing one ? If that's the case you can simply change your dispense event like this: public function dispense()
{
if (empty($this->bean->id)) {
$defaultValues = self::getDefaults();
foreach ($defaultValues as $key => $value) {
$this->{$key} = $value;
}
}
} |
I will try. Thanks a lot. |
I tried. But I think I can't influence the whole process. Based on the below code, when I call
I think in the below code, we should add one line code
|
Made some big edits to that answer, sorry about that. Ok I understand what your problem is. Let me strike that, #755 does fix the issue and doesn't seem to break any BC. @gabordemooij Using the proposal from #755 fixes the problem encountered here but doesn't prevent the code from the |
When I upgrade my code to Redbean 5.4 and turn on the partial bean mode, I found this issue I mentioned.
As Redbean recommends, I set up the default values to some specific columns before I use them.
And then I use the partial bean mode to store the columns updated rather than the entire bean.
But I found if I set up the default values, it will change the
changelist
in thebean
which is the foundation of the partial bean mode.I try to go through the code of
Redbean
. I found that when we useR::load
orR::find
, it will call thedispense
function which will influence thechangelist
.Maybe we can make a better mechanism for setting up the default values with the partial bean mode working well?
Below is the part of my test code.
The text was updated successfully, but these errors were encountered: