-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature: add isSet() method to identify properties without a value #11
Feature: add isSet() method to identify properties without a value #11
Conversation
…o fields that have no default defined.
Hi @stratease! I like this. I want to think through it a bit. The class Foo extends Model
{
protected $properties = [
"bar" => "int"
];
}
$foo = new Foo();
isset($foo->bar); // false Now it's not possible to know from this method whether a value started as null or was made null after the fact. For example, a model could be retrieved from the database, a property made null, and then the model saved. Or it could be a new model with a property explicitly set as null. It looks like you're using |
Correct, I'm with you there. Lots of nuance around checking an explicitly set
Not sure the "why" but it appears we define a default with this shape Thoughts? |
Ohhh! Right, hahah! I was thinking about the wrong thing. That's just a visual syntax sort of thing. My suggestion is to make |
Updated per comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! What a great addition, @stratease! 🙌
@stratease I'm trying to think. Is this change backwards-breaking in any way? I don't think so. We're not setting a null value in |
@JasonTheAdams I don't think it will but there might be a possibility if we assume it will always fill undefined attributes with a |
Avoid a false positive in fetching defaults with a check that validates whether one is truly set or not. This avoids situations where we might force a
null
into a database, instead of allowing the MySQL default to take precedence.