Closed treagod closed 8 months ago
Thanks for looking into that! 👍
This is definitely a good start! 🚀 I left a few comments below that we will have to address before merging this PR. The most important thing is that we need to add some logic in order to verify that the targeted field exists. Moreover, we should also update the
Marten::DB::Query::Set#count
so that it's possible to call the#count
query set method with a field name (updating theMarten::DB::Query::SQL::Query#count
method only isn't sufficient!).
One more question: There is also a #count
method for the raw_set.cr
. Should I adapt the API so that the method calls are the same? Even though the method is not calling #count
on the sql internally?
One more question: There is also a #count method for the raw_set.cr. Should I adapt the API so that the method calls are the same? Even though the method is not calling #count on the sql internally?
@treagod no need! For raw query sets we simply execute the specified raw SQL query and determine the number of records based on the obtained results. We wouldn't be able to do a count on a specific column in that situation.
This adds the ability to count records by a specific column name.
Closes #95