hi, all i am having a problem getting incorrect pager result - wrong total_entries in the following example.
package MyApp::Schema::UserPost; sub posts_rs { my $rs = shift; $rs->search( {}, { prefetch => { "post" => { "tags" => "tag" } }, order_by => [qw/ post.created / ], # distinct => 1, }); return $rs; } % perl -MMyApp -MData::Dumper -le '$rs=MyApp->schema("UserPost")->posts_rs; print Dumper $rs->pager' $VAR1 = bless( { 'total_entries' => '3', 'current_page' => 1, 'entries_per_page' => 10 }, 'Data::Page' ); % perl -MMyApp -MData::Dumper -le '@rs=MyApp->ds("UserPost")->posts_rs->all; print scalar @rs' 2 as you can see the total_entries is 3. however, the total number of posts is really 2. i think the wrong total_entries is due to the has_many relationship between 'Post' to 'Tag'. in this case, there are total 2 posts and one post has two tags and the other post has only 1 tag. FYI, here is the relationships defined in UserPost.pm # relationships in UserPost.pm __PACKAGE__->has_many('tags','MyApp::Schema::Result::UserTagPost','post_id'); __PACKAGE__->has_one('category','MyApp::Schema::Result::UserCategoryPost','category_id'); I have also looked at DISTINCT attr but i am stuck with an error: "Operand should contain 1 column(s)" how do i fix it? thanks, Qiang _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]