Permalink
Browse files

Warn on signs of Moose-borkage (in case it gets to be the first new())

  • Loading branch information...
1 parent 482a1cf commit e0de554e40cb58ae5f873784089b11b727079111 @ribasushi ribasushi committed Feb 26, 2013
Showing with 24 additions and 6 deletions.
  1. +4 −0 Changes
  2. +20 −6 lib/DBIx/Class/ResultSet.pm
View
@@ -1,5 +1,9 @@
Revision history for DBIx::Class
+ * New Features / Changes
+ - Debugging aid - warn on invalid result objects created by what
+ seems like an invalid inheritance hierarchy
+
* Fixes
- Fix another embarrassing regression preventing correct refining of
the search criteria on a prefetched relation (broken in 0.08205)
@@ -5,7 +5,7 @@ use warnings;
use base qw/DBIx::Class/;
use DBIx::Class::Carp;
use DBIx::Class::ResultSetColumn;
-use Scalar::Util qw/blessed weaken/;
+use Scalar::Util qw/blessed weaken reftype/;
use Try::Tiny;
use Data::Compare (); # no imports!!! guard against insane architecture
@@ -2324,15 +2324,29 @@ sub new_result {
my ($merged_cond, $cols_from_relations) = $self->_merge_with_rscond($values);
- my %new = (
+ my $new = $self->result_class->new({
%$merged_cond,
- @$cols_from_relations
+ ( @$cols_from_relations
? (-cols_from_relations => $cols_from_relations)
- : (),
+ : ()
+ ),
-result_source => $self->result_source, # DO NOT REMOVE THIS, REQUIRED
- );
+ });
+
+ if (
+ reftype($new) eq 'HASH'
+ and
+ ! keys %$new
+ and
+ blessed($new)
+ ) {
+ carp_unique (sprintf (
+ "%s->new returned a blessed empty hashref - a strong indicator something is wrong with its inheritance chain",
+ $self->result_class,
+ ));
+ }
- return $self->result_class->new(\%new);
+ $new;
}
# _merge_with_rscond

0 comments on commit e0de554

Please sign in to comment.