refactor: separate driver-specific find options#7192
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7192 +/- ##
==========================================
- Coverage 99.69% 99.62% -0.07%
==========================================
Files 252 252
Lines 22705 22765 +60
Branches 6156 6155 -1
==========================================
+ Hits 22636 22680 +44
- Misses 69 85 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e81ea94 to
5ebde31
Compare
5ebde31 to
5c9ff78
Compare
|
Thoughts about this @xcfox @boenrobot? I am a bit torn here. I like the outcome, but I don't like the implementation very much. |
|
I'm not a big fan of all the "as any" casts going on, even if they are just internal, rather than at the public api surface. I think every time you hit one, you're really exposing some design flaw. Not sure how to addrees them though... Not from the quick skim so far at least. |
|
We don't really depend on 3rd party types here, so we could maybe introduce a combined interface in core that would be used internally. Realistically, we already do those things a lot, that's what you get with making the public interface more strict. I wouldn't call this a design flaw at all. |
|
I roughly looked at the current implementation. Currently, there are some places inside that actively use To be honest, I think for complex functions, it's sufficient to ensure that the function's parameters and return values have the correct types. The variables inside the function are usually straightforward, and too many type annotations will make the internal code more verbose. That said, perhaps we can use some techniques, such as leaving export interface FindOptions extends Omit<InternalFindOptions, 'groupBy' | 'having' | 'maxTimeMS'...>export interface SqlFindOptions extends Omit<InternalFindOptions, 'maxTimeMS'...>export interface MongoFindOptions extends Omit<InternalFindOptions, 'groupBy' | 'having'...>This way, we can ensure the precision of options for each driver, while also guaranteeing the internal type checks of MikroORM. |
@mikro-orm/sql@mikro-orm/mongodbBreaking changes
SqlFindOptions(available via@mikro-orm/sqland all SQL driver packages)