Skip to content
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

missing features - select and include query fields is missing #8

Closed
Ali1Ammar opened this issue Sep 4, 2022 · 6 comments
Closed

missing features - select and include query fields is missing #8

Ali1Ammar opened this issue Sep 4, 2022 · 6 comments

Comments

@Ali1Ammar
Copy link
Collaborator

Ali1Ammar commented Sep 4, 2022

select and include query fields is not included in the dmmf so our code doesn't generate it
we should found a way to support it

@Ali1Ammar
Copy link
Collaborator Author

Ali1Ammar commented Sep 4, 2022

I think for language like dart to support like this feature we should create a new methods for each existing prisma method but has select and include fields and all it is output fields nullable

we could also use the same method but make all output field late

@Ali1Ammar Ali1Ammar changed the title missing features - select and include method is missing missing features - select and include query fields is missing Sep 4, 2022
@medz
Copy link
Owner

medz commented Sep 5, 2022

The simplest support solution might be to not deserialize the model, but return the Map type, but this is contrary to the original intention of Prisma.

We need to wait for the new version of Dart grammar, union types have been proposed in Dart Language: dart-lang/language#83

https://github.com/dart-lang/language/blob/master/working/0546-patterns/exhaustiveness.md#sealed-types

Before that, we want to support include and selected It may only return map type data, if you want to deserialize the model, you must get the support of the union type. Currently our union type in the input phase is a very plain design and adds complexity to passing parameters.

@medz
Copy link
Owner

medz commented Sep 5, 2022

@Ali1Ammar I think we can remove model deserialization and just traverse child members to resolve Enum types until the day Dart supports union types.

We can discuss this and invite more users to vote.

@Ali1Ammar
Copy link
Collaborator Author

I could 3 solution for this

return a map:

  1. easy to implement
  2. developer need to write the key my him self (or we generate some helper for them)
  3. need to handle null

make all field a late and only set what we receive:

  1. hard to implements as we need to write a custom json serializer
  2. developer need to remember what he select and only access this value
  3. no need to handle null
  4. no need to write a key

make all field nullable

  1. easy to implements (just make all field nullable)
  2. developer need to handle null for each field (maybe just use ! or writing if condition)
  3. no need to write a key string
  4. developer need to

we could apply one of this for all the existing methods
or we create a new methods that support select and include fields
my suggestion is keep the existing method as they are without include and select fields (as they support type safety better )
and create a new method in one of this way

  1- prisma.user.selectInclude.create(...);
  2- prisma.user.createWithInclude(...);

this new method will have all its output fields nullable

@medz
Copy link
Owner

medz commented Sep 6, 2022

Why don't we create a new branch to experiment with it? An experimental version is then released for users to choose from.

If we want to support type safety well and complete the select and include features it is difficult. Proposals for Dart union types have been around for ten years and have not been implemented. And there is nothing about the type of union in the proposal that is currently planned to be implemented.

Either we do not query the relationship and just return the table fields to support type safety as we do now. Either give up type safety and use a Map or a new method that returns a Map.

Personally I don't think it's a good idea to create a new method that makes it difficult for users to choose.

@medz
Copy link
Owner

medz commented Feb 17, 2023

select and include are no longer implemented, and include content is implemented using the Fluent API. This is done in the beta version of 3.0.

@medz medz closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants