X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSourceProxy%2FTable.pm;h=4cb733fae7c539ff543fa92175cf57a49d6d5f8f;hb=367eaf50970dd3fd223ce5e1f0337703f2a6c70e;hp=53dd26f031717f40babb23969febbc5d56c4385c;hpb=e570488ade8f327f47dd3318db3443a348d561d6;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index 53dd26f..4cb733f 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -9,7 +9,6 @@ use DBIx::Class::ResultSource::Table; use Scalar::Util 'blessed'; use namespace::clean; -# FIXME - both of these *PROBABLY* need to be 'inherited_ro_instance' type __PACKAGE__->mk_classaccessor(table_class => 'DBIx::Class::ResultSource::Table'); # FIXME: Doesn't actually do anything yet! __PACKAGE__->mk_group_accessors( inherited => 'table_alias' ); @@ -93,6 +92,29 @@ sub table { : undef ; + # Folks calling ->table on a class *might* expect the name + # to shift everywhere, but that can't happen + # So what we do is mark the ancestor as "dirty" + # even though it will have no "derived" link to the one we + # will use afterwards + if( + defined $ancestor + and + $ancestor->name ne $table + and + scalar $ancestor->__derived_instances + ) { + # Trigger the "descendants are dirty" logic, without giving + # it an explicit externally-callable interface + # This is ugly as sin, but likely saner in the long run + local $ancestor->{__in_rsrc_setter_callstack} = 1 + unless $ancestor->{__in_rsrc_setter_callstack}; + my $old_name = $ancestor->name; + $ancestor->set_rsrc_instance_specific_attribute( name => "\0" ); + $ancestor->set_rsrc_instance_specific_attribute( name => $old_name ); + } + + my $table_class = $class->table_class; $class->ensure_class_loaded($table_class);