-
Notifications
You must be signed in to change notification settings - Fork 18
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
Relation references within filters #680
Comments
Huh, that is weird... that should be:
Like the I guess technically we could update the runtime to recognize a Not sure whether to double-down on the current/expected API and find/fix the missing compile error, or lean into supporting this syntax as kosher, even if it is unintended. I think I'll probably start with trying to make sure this is a compile error, because if we're letting this in unintentionally, we're potentially letting other types in unintentionally as well... Thanks for reporting! I'll dig into this and try to find out what's happening. |
Just a small update, I remembered / rediscovered why this happens... Joist's filter types are what TS calls "weak types" where every field is optional, i.e. firstName?, lastName?, etc. Because of this, basically any type can technically structurally match an AuthorFilter or BookFilter etc. Even the {} empty type. I've found a few tickets in the TS repo mentioning that they've tried to recognize these weal types, I believe by heuristics like "there are literally no overlap in keys between these two types". But I'm not sure why those heuristics aren't working here. I'm still poking around though, and will hopefully find a good approach. |
microsoft/TypeScript#16047 is what should have fixed our filter's weak type check, afaiu. |
Ah, turns out both If I just manually remove |
I think personally I would prefer not allowing relations to be used in find filters, however b/c ManyToOneReference.id makes it structurally match the EntityFilter, it seems hard/not worth the complexity to prevent the ManyToOneReference in the EntityFilter mapped type. So instead just suppose m2os by calling `.id`.
🎉 This issue has been resolved in version 1.88.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I'm a bit unsure here if I've hit a runtime error or lack of type-safety here.
Imagine a UserAccount entity with a FK to a Organisation entity.
The reference here does not create a TS warning about passing this in to the
FilterWithAlias
.When executing this though, we get an error:
Digging in to this, it's coming from QueryParser.ts:L158 iterating though the properties of the ManyToOneReference object.
I'm assuming this isn't a runtime bug and that relations should be loaded for use within filters?
The text was updated successfully, but these errors were encountered: