From: Peter Rabbitson Date: Sun, 25 May 2014 09:52:13 +0000 (+0200) Subject: Improve complex order+prefetch exception message X-Git-Tag: v0.082800~210 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9736be652a2d4ce442c222c17ba5d47fff28bbed;p=dbsrgits%2FDBIx-Class.git Improve complex order+prefetch exception message --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 6c30f4a..ac9f581 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -436,6 +436,8 @@ mattp: Matt Phillips mdk: Mark Keating +mna: Maya + michaelr: Michael Reddick milki: Jonathan Chu diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index 4147e81..aa11286 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -653,9 +653,10 @@ sub _group_over_selection { } $self->throw_exception ( sprintf - 'A required group_by clause could not be constructed automatically due to a complex ' - . 'order_by criteria (%s). Either order_by columns only (no functions) or construct a suitable ' - . 'group_by by hand', + 'Unable to programatically derive a required group_by from the supplied ' + . 'order_by criteria. To proceed either add an explicit group_by, or ' + . 'simplify your order_by to only include plain columns ' + . '(supplied order_by: %s)', join ', ', map { "'$_'" } @$leftovers, ) if $leftovers; diff --git a/t/prefetch/with_limit.t b/t/prefetch/with_limit.t index 480dc40..4d08cd0 100644 --- a/t/prefetch/with_limit.t +++ b/t/prefetch/with_limit.t @@ -152,8 +152,8 @@ throws_ok ( {'tracks.title' => { '!=' => 'foo' }}, { order_by => \ 'some oddball literal sql', join => { cds => 'tracks' } } )->next - }, qr/A required group_by clause could not be constructed automatically/, -) || exit; + }, qr/Unable to programatically derive a required group_by from the supplied order_by criteria/, +); my $artist = $use_prefetch->search({'cds.title' => $artist_many_cds->cds->first->title })->next; is($artist->cds->count, 1, "count on search limiting prefetched has_many");