Discouraged legacy sugar, which does not even work properly with multicolumn
keys in scalar context. Mark properly as INDIRECT to ensure DBIC does not rely
on it anywhere
Also adjust the SanityChecker to not complain about shadowing of sugar methods
with generated ones (i.e. column accessors) - while unfortunate, this kind of
thing happens quite often (especially with such a generic name as 'id') and
warning about it would make no sense (left alone that methods which are
..._generated_from_resultsource_metadata generally do not invoke next::method
anyway)
use base qw/DBIx::Class::Row/;
+use DBIx::Class::_Util 'fail_on_internal_call';
+use namespace::clean;
+
=head1 NAME
DBIx::Class::PK - Primary Key class
=cut
-sub id {
- my ($self) = @_;
- $self->throw_exception( "Can't call id() as a class method" )
- unless ref $self;
- my @id_vals = $self->_ident_values;
- return (wantarray ? @id_vals : $id_vals[0]);
+sub id :DBIC_method_is_indirect_sugar {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
+
+ $_[0]->throw_exception( "Can't call id() as a class method" )
+ unless ref $_[0];
+
+ wantarray
+ ? $_[0]->_ident_values
+ : ($_[0]->_ident_values)[0] # FIXME - horrible horrible legacy crap
+ ;
}
sub _ident_values {
for (@$method_stack) {
push @$nonsugar_methods, $_ and next
- unless $_->{attributes}{DBIC_method_is_indirect_sugar};
+ unless(
+ $_->{attributes}{DBIC_method_is_indirect_sugar}
+ or
+ $_->{attributes}{DBIC_method_is_generated_from_resultsource_metadata}
+ );
push @err, {
overridden => {
{
package DB;
$fr = [ CORE::caller(1) ];
+
+ # screwing with $DB::args is rather volatile - be extra careful
+ no warnings 'uninitialized';
+
$argdesc =
( not defined $DB::args[0] ) ? 'UNAVAILABLE'
: ( length ref $DB::args[0] ) ? DBIx::Class::_Util::refdesc($DB::args[0])