-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix(database): handle virtual properties when generating a query from a model #971
base: main
Are you sure you want to change the base?
fix(database): handle virtual properties when generating a query from a model #971
Conversation
…odel class properties from being included in queries
I think this isn't the right approach, since readonly properties should also be writeable. The thing with the mapper is that it allows to create partial objects (which is why the constructor is skipped, you asked about it in #969 (comment) as wel). We allow partial objects because we support lazy relations. Anyway, long story just to say that, with Tempest's mappers, there could be scenarios where a readonly property isn't written to when the object was initially constructed, but it did load afterwards. So we cannot simply expand the readonly check. Shouldn't it work without those readonly property changes? Also we'd need a test :) |
…to a separate `isWritable()` method because it's fine to have a readonly property that gets set once, which is different to a hooked property with no `set` handler on it
Sorted - I've separated out the "is writable" check into it's own method. I realise that part's semi-unrelated to the Actually just thinking about it now, because there's likely to be logic on hooked properties should we even be trying to copy them over like this in the |
Isn't that what we're preventing with the added isWritable check? Maybe I misunderstand what you mean though |
The So both of these cases: public string $foo;
public string $bar = {
set(string $value) {
$this->bar = strtoupper($value);
}
} but not for this one because there's no setter: public string $bar = {
get => 'haha'
} which might lead to unexpected behaviour if the set hook does something less trivial - I wouldn't want someone to call I don't know the background about why |
Gotcha, thanks for explaining!
Convenience at the time 😇
I don't think we need to explicitly do anything with them for now. If people decide to add a set hook for a relation, I'd say they are on their own 😅 Would you be able to add a test for this one? |
My bad - in #966 I only did the "read" part, this PR does the "write" part that actually threw the original error in #962