You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var user = await prisma.user.findUnique(
select: UserSelect(
firstName: true, lastName: true, password: true, userId: true),
where: UserWhereUniqueInput(emailAddress: '[email protected]')
);
What is the expected behavior?
Only the selected fields (firstName, lastName, password, userId) should be returned.
What do you see instead?
Other unselected fields are also returned with null values.
Additional information
I encountered an issue where unselected fields are being returned as null in the response when using the select option with Prisma Dart. I expected Prisma to only return the fields I selected, but instead, it returns other fields as null.
The text was updated successfully, but these errors were encountered:
@Hackman-Adu Thanks for your feedback, but the requirement you reported cannot be implemented. (Maybe it will be implemented in the future when the macro is officially launched)
But for now, Dart does not distinguish between null input and no input. In Dart, they are all null types. We cannot dynamically construct the return type through select or include.
You should notice that in model.dart, all model classes are nullable fields.
I will keep this issue open and mark it as implementable when Dart supports it or we find other ways to support this behavior.
@medz Thanks for the prompt response. Yes, I realized that the unavailability of Dart macros could be the reason behind this limitation. I just wanted to bring it to your attention.
Currently, as a workaround, I am using an extension on maps to handle and filter out null values when select is applied. I appreciate your consideration of this issue and look forward to future updates. Thanks again!
What version of Prisma Dart is running?
5.2.0
What version of Prisma CLI is running?
5.20.0
What type of app are you using?
Dart Native (Server/CLI)
What database are you using?
MySQL
What steps can reproduce the bug?
What is the expected behavior?
Only the selected fields (firstName, lastName, password, userId) should be returned.
What do you see instead?
Other unselected fields are also returned with null values.
Additional information
I encountered an issue where unselected fields are being returned as null in the response when using the select option with Prisma Dart. I expected Prisma to only return the fields I selected, but instead, it returns other fields as null.
The text was updated successfully, but these errors were encountered: