Closed jcbriones closed 6 months ago
Okay, I just spent half an hour trying to make this work, and unfortunately it seems that the somewhat bizarre way that @Group
was designed prevents this from being possible without breaking the API - or at least I couldn't find a way to do it 😕. If I missed something, I would gladly welcome a PR, but absent that - and given that development focus is now on Fluent 5 - I have to declare this (despite very much agreeing that this is a rather glaring omission) "not planned" for Fluent 4.
No worries. I just made it to be just part of the main model. Thank you for looking into it though. Maybe I can try play around with it and might be able to get a fix. But I didn't know there's fluent 5 coming up as well. That's nice. Is that like a redesign?
Describe the issue
Querying group fields not available for use.
Vapor version
4.94.0
Operating system and version
MacOS 14.4.1
Swift version
5.10.0
Steps to reproduce
Using the instructions from the documentation: https://docs.vapor.codes/fluent/model/#group
Should have the following class:
User: Model
andPet: Fields
Outcome
When I ran
User.query(on: <Database>).field(\.$pet).all()
. This does not work and gets a compile error becauseGroupProperty
does not conform toQueryableProperty
. The error would be something likeInstance method 'field' requires that 'GroupProperty<User, Pet>' conform to 'QueryableProperty'
Also there is no way to only fetch single fields inside the group property like
User.query(on: <Database>).field(\.$pet.$name).all()
which should only get all names of the pets.Additional notes
No response