From: Jason M. Mills Date: Tue, 10 Feb 2009 00:23:28 +0000 (+0000) Subject: Modified fix - removed %done tracking and replaced with a more elegant and proper... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3d27f771a00a4ace223351c0ea8e7d8785bd86f3;p=dbsrgits%2FDBIx-Class-Historic.git Modified fix - removed %done tracking and replaced with a more elegant and proper isa() sorting. The core issue with this bug was that sub classes resultset class would be set before the related parent|super class was to have it's resultset class. This would cause problems since sub-classes inherit resultset classes from it's parent. Fix is simple, sort the source classes via sub-class last. --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 849f1dd..dc69062 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -208,17 +208,19 @@ sub load_namespaces { local *Class::C3::reinitialize = sub { }; use warnings 'redefine'; - my %done; - 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}; - $class->ensure_class_loaded($result_class); $result_class->source_name($result) unless $result_class->source_name; my $rs_class = delete $resultsets{$result}; my $rs_set = $result_class->resultset_class; - $done{$rs_set} = $rs_set unless exists $done{$rs_set}; + if($rs_set && $rs_set ne 'DBIx::Class::ResultSet') { - if($rs_class && !exists($done{$rs_set}) && $rs_class ne $rs_set) { + if($rs_class && $rs_class ne $rs_set) { warn "We found ResultSet class '$rs_class' for '$result', but it seems " . "that you had already set '$result' to use '$rs_set' instead"; }