-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Temporary workaround for Union-Types in the distant future #212
Comments
Alternatively, we construct a nested view type for nesting: where = PrismaUnion<A, PrismaUnion<B, C>> This will obviously increase the complexity of the condition. It is worth noting that this method is adopted by the early version 1.0. |
Dart 3 is out alongside Google I/O yesterday! looking forward for updates~ |
No Union-Types and macros, little pity. |
Is it possible to make union structures such as something below? class UnionNullableStringWhereClause {
factory string(String val);
factory null();
String? value;
bool isNull;
} By properly defining factory constructors it's possible to deduce whether the value is a string or a null. And by using a nullable |
I made this structure once, and the code size doubled. It doesn't feel like the best solution. Currently I'm thinking about dynamic or nested Union views. After dynamic, Dart 3 will migrate painlessly after the release of Union, while nested attempts will require a lot of code changes for subsequent upgrades. dynamic Advantages: Painless upgrades, Disadvantages: Developers must read the comments, otherwise they will not know the specific content that needs to be passed in. |
I haven't waited long for the Dart union types feature. PrismaUnion is built in the new version to implement structure nesting. Please follow #290 |
Temporary workaround for Union-Types in the distant future
In the planned full Prisma ORM feature support, we voted to wait for Dart 3 Union-Types support results.
But after months of waiting, the Dart language team is reluctant to announce any news and developments related to union types. My vision:
Disadvantage: It is impossible for users to know what the incoming type is without reading the documentation or source code.
Advantages: Completed ahead of time, when Dart Union-types are supported, we can produce types for them (dynamic is replaced by a specific union type)
The text was updated successfully, but these errors were encountered: