Hi Dan, I think aggregate functions should return zero if query is invalid. That would make sense.
Some time we will call Model.aggregate method to get a couple of data, like this: rating_avg, rating_max, rating_min = Post.all(:user_id => [1,2,3]).aggregate(:rating.avg, :rating.max, :rating.min) if user_id argument is a empty array, the aggregate method will just return a nil result. I think a array like [0, 0, 0] would be a better result in this case. On Sep 26, 3:20 pm, "Dan Kubb (dkubb)" <[email protected]> wrote: > Hi Jacques, > > > Seems like it could be fixed in either dm-aggregates or do_mysql. I > > sort of think dm-aggregates should check a record for new? before > > trying to run aggregate queries. Though it also probably makes sense > > to update do_mysql so it'll never construct queries with empty > > parenthesis. > > DM's own Query object should mark that kind of thing as invalid and > not even bother executing it. Doing an inclusion match with an empty > list will always return false, and there are checks for this inside DM > to short-circuit these types of obviously wrong queries, but I'm not > sure why it isn't catching this one. > > Can you create a ticket for this, and any other dm-aggregates issues > you come across? > > -- > > Dan > (dkubb) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
