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
I'd like to be able to do this (like in ActiveRecord):
User.select(:name)
From #215 and the docs, it seems like it's possible to specify a custom SELECT at the model level, but I'd like to be able to do this at the query level. As far as I can tell (it's been a while) ActiveRecord returns an instance of the model with only the selected fields populated, but personally I think this would be very useful even if it only returned an array, or, in the case of multiple columns, an array of hashes.
Willing to look into this myself and open a PR if this is straightforward enough + wanted, though I also noticed an open PR about ModelViews from some time ago.
The text was updated successfully, but these errors were encountered:
Serdnad
changed the title
Support custom select in queries
Support select in query builder
Sep 6, 2020
The biggest challenge with having a select that returns only the specified attributes in Crystal is that we then can't have the results as the actual object like what ActiveRecord does in Ruby. The typing is too strict for that, however, I do think there is value in having this method available if an array of the results is acceptible.
I'd like to be able to do this (like in ActiveRecord):
From #215 and the docs, it seems like it's possible to specify a custom SELECT at the model level, but I'd like to be able to do this at the query level. As far as I can tell (it's been a while) ActiveRecord returns an instance of the model with only the selected fields populated, but personally I think this would be very useful even if it only returned an array, or, in the case of multiple columns, an array of hashes.
Willing to look into this myself and open a PR if this is straightforward enough + wanted, though I also noticed an open PR about ModelViews from some time ago.
The text was updated successfully, but these errors were encountered: