[Dbix-class] having attribute with count
Les Fletcher
les at affinitycircles.com
Tue Jul 31 23:36:27 GMT 2007
Sorry, one of those order_by's should have been a group_by.
Les Fletcher wrote:
> I am building up a result set and am see difference between the actual
> selection of the objects from the database and counting of those same
> objects. The query has a prefetch, groupby, having and a limit
> clause. What I am seeing is that when I request the objects from the
> database the query is working just fine, but when I am doing a count,
> the having clause is dropped from the count query. In the source of
> resultset I see that the having attribute is deleted from time to time
> and then processed differently. Is there something that I can do to
> ensure that the having clause is used in the count? Thanks.
>
> Les
>
>
> The code is structured like this:
>
> sub get_rs {
> # returns a result set
> ...->search(
> {
> ...
> },
> {
> *group_by* => ...
> having => ...
> prefetch => ...
> order_by => ...
> }
> );
> }
>
> sub get_records {
> &get_rs->search(
> undef,
> {
> page => 1,
> rows => 10
> }
> )->all;
> }
>
> sub get_count {
> &get_rs->count;
> }
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
More information about the Dbix-class
mailing list