local *Class::C3::reinitialize = sub { };
use warnings 'redefine';
- foreach my $result (keys %results) {
+ # ensure classes are loaded and fetch properly sorted classes
+ $class->ensure_class_loaded($_) foreach(values %results);
+ my @subclass_last = sort { $results{$a}->isa($results{$b}) } keys(%results);
+
+ foreach my $result (@subclass_last) {
my $result_class = $results{$result};
- $result_class->source_name($result) unless $result_class->source_name;
- $class->ensure_class_loaded($result_class);
my $rs_class = delete $resultsets{$result};
my $rs_set = $result_class->resultset_class;