From: Peter Rabbitson Date: Fri, 15 Apr 2016 14:24:33 +0000 (+0200) Subject: More indirect call removals: the second part of 77c3a5dc X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e50536940;p=dbsrgits%2FDBIx-Class-Historic.git More indirect call removals: the second part of 77c3a5dc This may see like a random thing to do, especially given the late dev stage, but it is needed for the clean fix of rsrc duality several commits later. The spots were audited via "list all subs 10 lines or less": ~/devel/dbic$ find lib \ -name '*.pod' -prune \ -o -path lib/DBIx/Class/CDBICompat -prune \ -o -path lib/DBIx/Class/Admin -prune \ -o -path lib/DBIx/Class/Storage -prune \ -o -path lib/DBIx/Class/SQLMaker -prune \ -o -type f -exec perl -0777 -e ' $_ =~ /\S/ and $_ !~ /ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call/ and print "\n=====\n$ARGV\n=====\n\n$_\n\n\n" for (<> =~ / ( ^ (\s*) sub \s+ \w+ \s* \{ (?: [^\n]+? \} \s*? \n | (?: [^\n]* \n ){0,10}? ^ \2 \} ) ) /xmg) ' {} \; \ | less --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 79d7630..f1c80ae 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -53,7 +53,7 @@ sub inject_base { sub MODIFY_CODE_ATTRIBUTES { my ($class,$code,@attrs) = @_; - $class->mk_classdata('__attr_cache' => {}) + $class->mk_classaccessor('__attr_cache' => {}) unless $class->can('__attr_cache'); $class->__attr_cache->{$code} = [@attrs]; return (); diff --git a/lib/DBIx/Class/AccessorGroup.pm b/lib/DBIx/Class/AccessorGroup.pm index 12a8744..01a5559 100644 --- a/lib/DBIx/Class/AccessorGroup.pm +++ b/lib/DBIx/Class/AccessorGroup.pm @@ -5,16 +5,21 @@ use warnings; use base qw/Class::Accessor::Grouped/; use Scalar::Util qw/weaken blessed/; +use DBIx::Class::_Util 'fail_on_internal_call'; use namespace::clean; sub mk_classdata { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; shift->mk_classaccessor(@_); } sub mk_classaccessor { my $self = shift; $self->mk_group_accessors('inherited', $_[0]); - $self->set_inherited(@_) if @_ > 1; + (@_ > 1) + ? $self->set_inherited(@_) + : ( DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call ) + ; } my $successfully_loaded_components; diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index f3e6b58..ed8ae7d 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -92,7 +92,7 @@ sub _build_schema { my ($self) = @_; $self->connect_info->[3]{ignore_version} = 1; - return $self->schema_class->connect(@{$self->connect_info}); + return $self->schema_class->clone->connection(@{$self->connect_info}); } =head2 resultset diff --git a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm index 16f2164..f7ba085 100644 --- a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm +++ b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; -__PACKAGE__->mk_classdata('__AutoCommit'); +__PACKAGE__->mk_group_accessors( inherited => '__AutoCommit' ); sub set_column { my $self = shift; diff --git a/lib/DBIx/Class/CDBICompat/LazyLoading.pm b/lib/DBIx/Class/CDBICompat/LazyLoading.pm index a9e41af..b79a096 100644 --- a/lib/DBIx/Class/CDBICompat/LazyLoading.pm +++ b/lib/DBIx/Class/CDBICompat/LazyLoading.pm @@ -98,7 +98,7 @@ sub _flesh { my %want; $want{$_} = 1 for map { keys %{$self->_column_groups->{$_}} } @groups; if (my @want = grep { !exists $self->{'_column_data'}{$_} } keys %want) { - my $cursor = $self->result_source->storage->select( + my $cursor = $self->result_source->schema->storage->select( $self->result_source->name, \@want, \$self->_ident_cond, { bind => [ $self->_ident_values ] }); #my $sth = $self->storage->select($self->_table_name, \@want, diff --git a/lib/DBIx/Class/CDBICompat/Relationships.pm b/lib/DBIx/Class/CDBICompat/Relationships.pm index 658305d..a5bfa5e 100644 --- a/lib/DBIx/Class/CDBICompat/Relationships.pm +++ b/lib/DBIx/Class/CDBICompat/Relationships.pm @@ -129,7 +129,7 @@ sub has_many { if (@f_method) { quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel), { '$rf' => \sub { my $o = shift; $o = $o->$_ for @f_method; $o } }; - my $rs = shift->search_related( %s => @_); + my $rs = shift->related_resultset(%s)->search_rs( @_); $rs->{attrs}{record_filter} = $rf; return (wantarray ? $rs->all : $rs); EOC @@ -213,7 +213,7 @@ sub search { } sub new_related { - return shift->search_related(shift)->new_result(shift); + return shift->search_related(shift)->new_result(@_); } =head1 FURTHER QUESTIONS? diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index b7e5394..235b6bf 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -61,7 +61,7 @@ it. See resolve_class below. =cut -__PACKAGE__->mk_classdata('class_resolver' => +__PACKAGE__->mk_classaccessor('class_resolver' => 'DBIx::Class::ClassResolver::PassThrough'); =begin hidden @@ -101,7 +101,7 @@ sub setup_schema_instance { my $class = shift; my $schema = {}; bless $schema, 'DBIx::Class::Schema'; - $class->mk_classdata('schema_instance' => $schema); + $class->mk_classaccessor('schema_instance' => $schema); } =begin hidden @@ -189,7 +189,7 @@ Returns an instance of the result source for this class =cut -__PACKAGE__->mk_classdata('_result_source_instance' => []); +__PACKAGE__->mk_classaccessor('_result_source_instance' => []); # Yep. this is horrific. Basically what's happening here is that # (with good reason) DBIx::Class::Schema copies the result source for diff --git a/lib/DBIx/Class/FilterColumn.pm b/lib/DBIx/Class/FilterColumn.pm index b7860c9..18f99a8 100644 --- a/lib/DBIx/Class/FilterColumn.pm +++ b/lib/DBIx/Class/FilterColumn.pm @@ -9,13 +9,13 @@ use namespace::clean; sub filter_column { my ($self, $col, $attrs) = @_; - my $colinfo = $self->column_info($col); + my $colinfo = $self->result_source_instance->column_info($col); $self->throw_exception("FilterColumn can not be used on a column with a declared InflateColumn inflator") if defined $colinfo->{_inflate_info} and $self->isa('DBIx::Class::InflateColumn'); $self->throw_exception("No such column $col to filter") - unless $self->has_column($col); + unless $self->result_source_instance->has_column($col); $self->throw_exception('filter_column expects a hashref of filter specifications') unless ref $attrs eq 'HASH'; diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index 27bde58..08b1b54 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -87,13 +87,13 @@ L sub inflate_column { my ($self, $col, $attrs) = @_; - my $colinfo = $self->column_info($col); + my $colinfo = $self->result_source_instance->column_info($col); $self->throw_exception("InflateColumn can not be used on a column with a declared FilterColumn filter") if defined $colinfo->{_filter_info} and $self->isa('DBIx::Class::FilterColumn'); $self->throw_exception("No such column $col to inflate") - unless $self->has_column($col); + unless $self->result_source_instance->has_column($col); $self->throw_exception("inflate_column needs attr hashref") unless ref $attrs eq 'HASH'; $colinfo->{_inflate_info} = $attrs; diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 8ccdf7a..bb6223d 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -219,7 +219,7 @@ sub _deflate_from_datetime { } sub _datetime_parser { - shift->result_source->storage->datetime_parser (@_); + shift->result_source->schema->storage->datetime_parser (@_); } sub _post_inflate_datetime { diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 0c572e8..bf7f954 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -106,7 +106,7 @@ positional value of each record. Defaults to "position". =cut -__PACKAGE__->mk_classdata( 'position_column' => 'position' ); +__PACKAGE__->mk_classaccessor( 'position_column' => 'position' ); =head2 grouping_column @@ -118,7 +118,7 @@ ordered lists within the same table. =cut -__PACKAGE__->mk_classdata( 'grouping_column' ); +__PACKAGE__->mk_group_accessors( inherited => 'grouping_column' ); =head2 null_position_value @@ -133,7 +133,7 @@ indeed start from 0. =cut -__PACKAGE__->mk_classdata( 'null_position_value' => 0 ); +__PACKAGE__->mk_classaccessor( 'null_position_value' => 0 ); =head2 siblings @@ -680,7 +680,7 @@ L below. Defaults to 1. =cut -__PACKAGE__->mk_classdata( '_initial_position_value' => 1 ); +__PACKAGE__->mk_classaccessor( '_initial_position_value' => 1 ); =head2 _next_position_value diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm index e34294d..fae251e 100644 --- a/lib/DBIx/Class/Relationship/Accessor.pm +++ b/lib/DBIx/Class/Relationship/Accessor.pm @@ -54,7 +54,7 @@ sub add_relationship_accessor { $rsrc->relationship_info(%1$s)->{attrs}{undef_on_null_fk} ); - my $val = $self->search_related( %1$s )->single; + my $val = $self->related_resultset( %1$s )->single; return $val unless $val; # $val instead of undef so that null-objects can go through return $self->{_relationship_data}{%1$s} = $val; @@ -63,14 +63,16 @@ EOC } elsif ($acc_type eq 'filter') { $class->throw_exception("No such column '$rel' to filter") - unless $class->has_column($rel); + unless $class->result_source_instance->has_column($rel); - my $f_class = $class->relationship_info($rel)->{class}; + my $f_class = $class->result_source_instance + ->relationship_info($rel) + ->{class}; $class->inflate_column($rel, { inflate => sub { my ($val, $self) = @_; - return $self->find_or_new_related($rel, {}, {}); + return $self->find_or_new_related($rel, {}); }, deflate => sub { my ($val, $self) = @_; @@ -98,11 +100,11 @@ EOC } elsif ($acc_type eq 'multi') { - quote_sub "${class}::${rel}_rs", "shift->search_related_rs( $rel => \@_ )"; - quote_sub "${class}::add_to_${rel}", "shift->create_related( $rel => \@_ )"; + quote_sub "${class}::${rel}_rs", "shift->related_resultset('$rel')->search_rs( \@_ )"; + quote_sub "${class}::add_to_${rel}", "shift->related_resultset('$rel')->new_result( \@_ )->insert"; quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel ); DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = DBIx::Class::_Util::fail_on_internal_wantarray; - shift->search_related( %s => @_ ) + shift->related_resultset(%s)->search( @_ ) EOC } else { diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index f5d34f8..323c31e 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -7,7 +7,7 @@ use base qw/DBIx::Class/; use Scalar::Util qw/weaken blessed/; use Try::Tiny; -use DBIx::Class::_Util 'UNRESOLVABLE_CONDITION'; +use DBIx::Class::_Util qw( UNRESOLVABLE_CONDITION fail_on_internal_call ); use namespace::clean; =head1 NAME @@ -565,7 +565,7 @@ sub related_resultset { $rsrc->resultset->search( $self->ident_condition($obj_table_alias), { alias => $obj_table_alias }, - )->search_related('me', undef, $rel_info->{attrs}) + )->related_resultset('me')->search(undef, $rel_info->{attrs}) } else { @@ -612,7 +612,8 @@ See L for more information. =cut sub search_related { - return shift->related_resultset(shift)->search(@_); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->related_resultset(shift)->search(@_); } =head2 search_related_rs @@ -623,7 +624,8 @@ it guarantees a resultset, even in list context. =cut sub search_related_rs { - return shift->related_resultset(shift)->search_rs(@_); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->related_resultset(shift)->search_rs(@_) } =head2 count_related @@ -642,7 +644,8 @@ current result or where conditions. =cut sub count_related { - shift->search_related(@_)->count; + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->related_resultset(shift)->search_rs(@_)->count; } =head2 new_related @@ -665,7 +668,7 @@ your storage until you call L on it. sub new_related { my ($self, $rel, $data) = @_; - return $self->search_related($rel)->new_result( $self->result_source->_resolve_relationship_condition ( + $self->related_resultset($rel)->new_result( $self->result_source->_resolve_relationship_condition ( infer_values_based_on => $data, rel_name => $rel, self_result_object => $self, @@ -719,7 +722,8 @@ See L for details. sub find_related { #my ($self, $rel, @args) = @_; - return shift->search_related(shift)->find(@_); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + return shift->related_resultset(shift)->find(@_); } =head2 find_or_new_related @@ -739,8 +743,9 @@ for details. sub find_or_new_related { my $self = shift; - my $obj = $self->find_related(@_); - return defined $obj ? $obj : $self->new_related(@_); + my $rel = shift; + my $obj = $self->related_resultset($rel)->find(@_); + return defined $obj ? $obj : $self->related_resultset($rel)->new_result(@_); } =head2 find_or_create_related @@ -760,8 +765,9 @@ L for details. sub find_or_create_related { my $self = shift; - my $obj = $self->find_related(@_); - return (defined($obj) ? $obj : $self->create_related(@_)); + my $rel = shift; + my $obj = $self->related_resultset($rel)->find(@_); + return (defined($obj) ? $obj : $self->related_resultset($rel)->new_result(@_)->insert); } =head2 update_or_create_related @@ -781,6 +787,7 @@ L for details. sub update_or_create_related { #my ($self, $rel, @args) = @_; + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; shift->related_resultset(shift)->update_or_create(@_); } @@ -868,8 +875,9 @@ And returns the result of that. sub delete_related { my $self = shift; - my $obj = $self->search_related(@_)->delete; - delete $self->{related_resultsets}->{$_[0]}; + my $rel = shift; + my $obj = $self->related_resultset($rel)->search_rs(@_)->delete; + delete $self->{related_resultsets}->{$rel}; return $obj; } diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index a3e7dbc..cadca92 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -39,7 +39,7 @@ sub belongs_to { $class->throw_exception( "No such column '$f_key' declared yet on ${class} ($guess)" - ) unless $class->has_column($f_key); + ) unless $class->result_source_instance->has_column($f_key); $class->ensure_class_loaded($f_class); my $f_rsrc = dbic_internal_try { @@ -81,7 +81,7 @@ sub belongs_to { and (keys %$cond)[0] =~ /^foreign\./ and - $class->has_column($rel) + $class->result_source_instance->has_column($rel) ) ? 'filter' : 'single'; my $fk_columns = ($acc_type eq 'single' and ref $cond eq 'HASH') diff --git a/lib/DBIx/Class/Relationship/CascadeActions.pm b/lib/DBIx/Class/Relationship/CascadeActions.pm index 59aefc1..6fcfbe6 100644 --- a/lib/DBIx/Class/Relationship/CascadeActions.pm +++ b/lib/DBIx/Class/Relationship/CascadeActions.pm @@ -29,7 +29,7 @@ sub delete { my $ret = $self->next::method(@rest); foreach my $rel (@cascade) { - if( my $rel_rs = dbic_internal_try { $self->search_related($rel) } ) { + if( my $rel_rs = dbic_internal_try { $self->related_resultset($rel) } ) { $rel_rs->delete_all; } else { carp "Skipping cascade delete on relationship '$rel' - related resultsource '$rels{$rel}{class}' is not registered with this schema"; diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 3141259..665d131 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -98,8 +98,8 @@ sub _validate_has_one_condition { my $key = $1; $class->throw_exception("Defining rel on ${class} that includes '$key' but no such column defined here yet") - unless $class->has_column($key); - my $column_info = $class->column_info($key); + unless $class->result_source_instance->has_column($key); + my $column_info = $class->result_source_instance->column_info($key); if ( $column_info->{is_nullable} ) { carp(qq'"might_have/has_one" must not be on columns with is_nullable set to true ($class/$key). This might indicate an incorrect use of those relationship helpers instead of belongs_to.'); } diff --git a/lib/DBIx/Class/Relationship/ManyToMany.pm b/lib/DBIx/Class/Relationship/ManyToMany.pm index c000a84..1cf6b02 100644 --- a/lib/DBIx/Class/Relationship/ManyToMany.pm +++ b/lib/DBIx/Class/Relationship/ManyToMany.pm @@ -65,14 +65,14 @@ EOW # this little horror is there replicating a deprecation from # within search_rs() itself - shift->search_related_rs( q{%1$s} ) - ->search_related_rs( - q{%2$s}, - undef, - ( @_ > 1 and ref $_[-1] eq 'HASH' ) - ? { %%$rel_attrs, %%{ pop @_ } } - : $rel_attrs - )->search_rs(@_) + shift->related_resultset( q{%1$s} ) + ->related_resultset( q{%2$s} ) + ->search_rs ( + undef, + ( @_ > 1 and ref $_[-1] eq 'HASH' ) + ? { %%$rel_attrs, %%{ pop @_ } } + : $rel_attrs + )->search_rs(@_) ; EOC @@ -164,13 +164,13 @@ EOC # if there is a where clause in the attributes, ensure we only delete # rows that are within the where restriction - $self->search_related( - q{%3$s}, - ( $rel_attrs->{where} - ? ( $rel_attrs->{where}, { join => q{%4$s} } ) - : () - ) - )->delete; + $self->related_resultset( q{%3$s} ) + ->search_rs( + ( $rel_attrs->{where} + ? ( $rel_attrs->{where}, { join => q{%4$s} } ) + : () + ) + )->delete; # add in the set rel objects $self->%2$s( @@ -187,7 +187,7 @@ EOC $_[0]->throw_exception("'%1$s' expects an object") unless defined Scalar::Util::blessed( $_[1] ); - $_[0]->search_related_rs( q{%2$s} ) + $_[0]->related_resultset( q{%2$s} ) ->search_rs( $_[1]->ident_condition( q{%3$s} ), { join => q{%3$s} } ) ->delete; EOC diff --git a/lib/DBIx/Class/Relationship/ProxyMethods.pm b/lib/DBIx/Class/Relationship/ProxyMethods.pm index 0db5780..f7585a7 100644 --- a/lib/DBIx/Class/Relationship/ProxyMethods.pm +++ b/lib/DBIx/Class/Relationship/ProxyMethods.pm @@ -28,7 +28,7 @@ sub proxy_to_related { my $self = shift; my $relobj = $self->%1$s; if (@_ && !defined $relobj) { - $relobj = $self->create_related( %1$s => { %2$s => $_[0] } ); + $relobj = $self->related_resultset(q{%1$s})->new_result({ %2$s => $_[0] })->insert; @_ = (); } $relobj ? $relobj->%2$s(@_) : undef; diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 1231a07..6dbc7ca 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -988,6 +988,7 @@ See also L. =cut sub search_related { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; return shift->related_resultset(shift)->search(@_); } @@ -999,6 +1000,7 @@ it guarantees a resultset, even in list context. =cut sub search_related_rs { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; return shift->related_resultset(shift)->search_rs(@_); } @@ -1022,7 +1024,7 @@ sub cursor { return $self->{cursor} ||= do { my $attrs = $self->_resolved_attrs; - $self->result_source->storage->select( + $self->result_source->schema->storage->select( $attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs ); }; @@ -1095,7 +1097,7 @@ sub single { } } - my $data = [ $self->result_source->storage->select_single( + my $data = [ $self->result_source->schema->storage->select_single( $attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs )]; @@ -1122,9 +1124,7 @@ Returns a L instance for a column of the ResultSet =cut sub get_column { - my ($self, $column) = @_; - my $new = DBIx::Class::ResultSetColumn->new($self, $column); - return $new; + DBIx::Class::ResultSetColumn->new(@_); } =head2 search_like @@ -1649,7 +1649,7 @@ sub _count_rs { # overwrite the selector (supplied by the storage) $rsrc->resultset_class->new($rsrc, { %$tmp_attrs, - select => $rsrc->storage->_count_select ($rsrc, $attrs), + select => $rsrc->schema->storage->_count_select ($rsrc, $attrs), as => 'count', })->get_column ('count'); } @@ -1680,7 +1680,7 @@ sub _count_subq_rs { # Calculate subquery selector if (my $g = $sub_attrs->{group_by}) { - my $sql_maker = $rsrc->storage->sql_maker; + my $sql_maker = $rsrc->schema->storage->sql_maker; # necessary as the group_by may refer to aliased functions my $sel_index; @@ -1747,7 +1747,7 @@ sub _count_subq_rs { return $rsrc->resultset_class ->new ($rsrc, $sub_attrs) ->as_subselect_rs - ->search ({}, { columns => { count => $rsrc->storage->_count_select ($rsrc, $attrs) } }) + ->search ({}, { columns => { count => $rsrc->schema->storage->_count_select ($rsrc, $attrs) } }) ->get_column ('count'); } @@ -1770,7 +1770,10 @@ with the passed arguments, then L. =cut -sub count_literal { shift->search_literal(@_)->count; } +sub count_literal { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->search_literal(@_)->count +} =head2 all @@ -1848,6 +1851,7 @@ an object for the first result (or C if the resultset is empty). =cut sub first { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; return $_[0]->reset->next; } @@ -1904,7 +1908,7 @@ sub _rs_update_delete { # a condition containing 'me' or other table prefixes will not work # at all. Tell SQLMaker to dequalify idents via a gross hack. $cond = do { - my $sqla = $rsrc->storage->sql_maker; + my $sqla = $rsrc->schema->storage->sql_maker; local $sqla->{_dequalify_idents} = 1; \[ $sqla->_recurse_where($self->{cond}) ]; }; @@ -2413,7 +2417,7 @@ sub populate { ### main source data # FIXME - need to switch entirely to a coderef-based thing, # so that large sets aren't copied several times... I think - $rsrc->storage->_insert_bulk( + $rsrc->schema->storage->_insert_bulk( $rsrc, [ @$colnames, sort keys %$rs_data ], [ map { @@ -2564,11 +2568,8 @@ Passes the hashref of input on to L. sub new_result { my ($self, $values) = @_; - $self->throw_exception( "new_result takes only one argument - a hashref of values" ) - if @_ > 2; - - $self->throw_exception( "Result object instantiation requires a hashref as argument" ) - unless (ref $values eq 'HASH'); + $self->throw_exception( "Result object instantiation requires a single hashref argument" ) + if @_ > 2 or ref $values ne 'HASH'; my ($merged_cond, $cols_from_relations) = $self->_merge_with_rscond($values); @@ -2732,7 +2733,7 @@ sub as_query { my $attrs = { %{ $self->_resolved_attrs } }; - my $aq = $self->result_source->storage->_select_args_to_query ( + my $aq = $self->result_source->schema->storage->_select_args_to_query ( $attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs ); @@ -3185,7 +3186,7 @@ sub is_paged { sub is_ordered { my ($self) = @_; - return scalar $self->result_source->storage->_extract_order_criteria($self->{attrs}{order_by}); + return scalar $self->result_source->schema->storage->_extract_order_criteria($self->{attrs}{order_by}); } =head2 related_resultset @@ -3714,7 +3715,7 @@ sub _resolved_attrs { else { $attrs->{_grouped_by_distinct} = 1; # distinct affects only the main selection part, not what prefetch may add below - ($attrs->{group_by}, my $new_order) = $source->storage->_group_over_selection($attrs); + ($attrs->{group_by}, my $new_order) = $source->schema->storage->_group_over_selection($attrs); # FIXME possibly ignore a rewritten order_by (may turn out to be an issue) # The thinking is: if we are collapsing the subquerying prefetch engine will diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 8d9d7a3..71cd52c 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -5,7 +5,7 @@ use warnings; use base 'DBIx::Class'; use DBIx::Class::Carp; -use DBIx::Class::_Util 'fail_on_internal_wantarray'; +use DBIx::Class::_Util qw( fail_on_internal_wantarray fail_on_internal_call ); use namespace::clean; =head1 NAME @@ -254,7 +254,7 @@ sub single { my $self = shift; my $attrs = $self->_resultset->_resolved_attrs; - my ($row) = $self->_resultset->result_source->storage->select_single( + my ($row) = $self->_resultset->result_source->schema->storage->select_single( $attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs ); @@ -279,7 +279,8 @@ resultset (or C if there are none). =cut sub min { - return shift->func('MIN'); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func('MIN'); } =head2 min_rs @@ -298,7 +299,10 @@ Wrapper for ->func_rs for function MIN(). =cut -sub min_rs { return shift->func_rs('MIN') } +sub min_rs { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func_rs('MIN') +} =head2 max @@ -318,7 +322,8 @@ resultset (or C if there are none). =cut sub max { - return shift->func('MAX'); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func('MAX'); } =head2 max_rs @@ -337,7 +342,10 @@ Wrapper for ->func_rs for function MAX(). =cut -sub max_rs { return shift->func_rs('MAX') } +sub max_rs { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func_rs('MAX') +} =head2 sum @@ -357,7 +365,8 @@ the resultset. Use on varchar-like columns at your own risk. =cut sub sum { - return shift->func('SUM'); + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func('SUM'); } =head2 sum_rs @@ -376,7 +385,10 @@ Wrapper for ->func_rs for function SUM(). =cut -sub sum_rs { return shift->func_rs('SUM') } +sub sum_rs { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->func_rs('SUM') +} =head2 func @@ -491,7 +503,7 @@ sub _resultset { # collapse the selector to a literal so that it survives the distinct parse # if it turns out to be an aggregate - at least the user will get a proper exception # instead of silent drop of the group_by altogether - $select = \[ $rsrc->storage->sql_maker->_recurse_fields($select) ]; + $select = \[ $rsrc->schema->storage->sql_maker->_recurse_fields($select) ]; } } diff --git a/lib/DBIx/Class/ResultSetManager.pm b/lib/DBIx/Class/ResultSetManager.pm index 1c7cf45..3ae9502 100644 --- a/lib/DBIx/Class/ResultSetManager.pm +++ b/lib/DBIx/Class/ResultSetManager.pm @@ -29,8 +29,9 @@ appropriate My::Schema::ResultSet::* classes for it to pick up."; =cut -__PACKAGE__->mk_classdata($_) - for qw/ base_resultset_class table_resultset_class_suffix /; +__PACKAGE__->mk_group_accessors(inherited => qw( + base_resultset_class table_resultset_class_suffix +)); __PACKAGE__->base_resultset_class('DBIx::Class::ResultSet'); __PACKAGE__->table_resultset_class_suffix('::_resultset'); diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index d2cc10f..aacf125 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -9,7 +9,7 @@ __PACKAGE__->load_components(qw( )); use DBIx::Class::Carp; -use DBIx::Class::_Util qw( UNRESOLVABLE_CONDITION dbic_internal_try ); +use DBIx::Class::_Util qw( UNRESOLVABLE_CONDITION dbic_internal_try fail_on_internal_call ); use SQL::Abstract 'is_literal_value'; use Devel::GlobalDestruction; use Scalar::Util qw/blessed weaken isweak/; @@ -28,7 +28,7 @@ __PACKAGE__->mk_group_accessors(component_class => qw/ result_class /); -__PACKAGE__->mk_classdata( sqlt_deploy_callback => 'default_sqlt_deploy_hook' ); +__PACKAGE__->mk_classaccessor( sqlt_deploy_callback => 'default_sqlt_deploy_hook' ); =head1 NAME @@ -402,7 +402,7 @@ sub column_info { if ( ! $self->_columns->{$column}{data_type} and ! $self->{_columns_info_loaded} and $self->column_info_from_storage - and my $stor = dbic_internal_try { $self->storage } ) + and my $stor = dbic_internal_try { $self->schema->storage } ) { $self->{_columns_info_loaded}++; @@ -480,7 +480,7 @@ sub columns_info { and grep { ! $_->{data_type} } values %$colinfo and - my $stor = dbic_internal_try { $self->storage } + my $stor = dbic_internal_try { $self->schema->storage } ) { $self->{_columns_info_loaded}++; @@ -578,7 +578,11 @@ sub remove_columns { $self->_ordered_columns([ grep { not $to_remove{$_} } @{$self->_ordered_columns} ]); } -sub remove_column { shift->remove_columns(@_); } # DO NOT CHANGE THIS TO GLOB +# DO NOT CHANGE THIS TO A GLOB +sub remove_column { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->remove_columns(@_) +} =head2 set_primary_key @@ -1254,7 +1258,10 @@ Returns the L for the current schema. =cut -sub storage { shift->schema->storage; } +sub storage { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + $_[0]->schema->storage +} =head2 add_relationship @@ -1377,7 +1384,7 @@ Returns all relationship names for this source. =cut sub relationships { - return keys %{shift->_relationships}; + keys %{$_[0]->_relationships}; } =head2 relationship_info @@ -1559,7 +1566,7 @@ sub _minimal_valueset_satisfying_constraint { $args->{columns_info} ||= $self->columns_info; - my $vals = $self->storage->_extract_fixed_condition_columns( + my $vals = $self->schema->storage->_extract_fixed_condition_columns( $args->{values}, ($args->{carp_on_nulls} ? 'consider_nulls' : undef ), ); @@ -1648,7 +1655,7 @@ sub _resolve_join { $force_left ||= lc($rel_info->{attrs}{join_type}||'') eq 'left'; # the actual seen value will be incremented by the recursion - my $as = $self->storage->relname_to_table_alias( + my $as = $self->schema->storage->relname_to_table_alias( $rel, ($seen->{$rel} && $seen->{$rel} + 1) ); @@ -1667,7 +1674,7 @@ sub _resolve_join { } else { my $count = ++$seen->{$join}; - my $as = $self->storage->relname_to_table_alias( + my $as = $self->schema->storage->relname_to_table_alias( $join, ($count > 1 && $count) ); diff --git a/lib/DBIx/Class/ResultSource/Table.pm b/lib/DBIx/Class/ResultSource/Table.pm index ac7d308..b6add2a 100644 --- a/lib/DBIx/Class/ResultSource/Table.pm +++ b/lib/DBIx/Class/ResultSource/Table.pm @@ -26,7 +26,7 @@ Returns the FROM entry for the table (i.e. the table name) =cut -sub from { shift->name; } +sub from { $_[0]->name } =head1 FURTHER QUESTIONS? diff --git a/lib/DBIx/Class/ResultSourceProxy.pm b/lib/DBIx/Class/ResultSourceProxy.pm index 62c0564..94009a5 100644 --- a/lib/DBIx/Class/ResultSourceProxy.pm +++ b/lib/DBIx/Class/ResultSourceProxy.pm @@ -8,7 +8,7 @@ use base 'DBIx::Class'; use mro 'c3'; use Scalar::Util 'blessed'; -use DBIx::Class::_Util 'quote_sub'; +use DBIx::Class::_Util qw( quote_sub fail_on_internal_call ); use namespace::clean; __PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name'); @@ -37,7 +37,10 @@ sub add_columns { } } -sub add_column { shift->add_columns(@_) } +sub add_column { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->add_columns(@_) +} sub add_relationship { @@ -49,7 +52,10 @@ sub add_relationship { # legacy resultset_class accessor, seems to be used by cdbi only -sub iterator_class { shift->result_source_instance->resultset_class(@_) } +sub iterator_class { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->result_source_instance->resultset_class(@_) +} for my $method_to_proxy (qw/ source_info diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index 647a408..d6bac68 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -9,20 +9,20 @@ use DBIx::Class::ResultSource::Table; use Scalar::Util 'blessed'; use namespace::clean; -__PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table'); +__PACKAGE__->mk_classaccessor(table_class => 'DBIx::Class::ResultSource::Table'); -__PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do - # anything yet! +# FIXME: Doesn't actually do anything yet! +__PACKAGE__->mk_group_accessors( inherited => 'table_alias' ); sub _init_result_source_instance { my $class = shift; - $class->mk_classdata('result_source_instance') - unless $class->can('result_source_instance'); + $class->mk_group_accessors( inherited => 'result_source_instance' ) + unless $class->can('result_source_instance'); my $table = $class->result_source_instance; - my $class_has_table_instance = ($table and $table->result_class eq $class); - return $table if $class_has_table_instance; + return $table + if $table and $table->result_class eq $class; my $table_class = $class->table_class; $class->ensure_class_loaded($table_class); @@ -96,7 +96,7 @@ sub table { }); } - $class->mk_classdata('result_source_instance') + $class->mk_group_accessors(inherited => 'result_source_instance') unless $class->can('result_source_instance'); $class->result_source_instance($table); diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 5c4cead..f42092a 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -6,7 +6,7 @@ use warnings; use base qw/DBIx::Class/; use Scalar::Util 'blessed'; -use DBIx::Class::_Util 'dbic_internal_try'; +use DBIx::Class::_Util qw( dbic_internal_try fail_on_internal_call ); use DBIx::Class::Carp; use SQL::Abstract qw( is_literal_value is_plain_value ); @@ -343,7 +343,7 @@ sub insert { $self->throw_exception("No result_source set on this object; can't insert") unless $rsrc; - my $storage = $rsrc->storage; + my $storage = $rsrc->schema->storage; my $rollback_guard; @@ -549,7 +549,7 @@ sub update { $self->throw_exception( "Not in database" ) unless $self->in_storage; - my $rows = $self->result_source->storage->update( + my $rows = $self->result_source->schema->storage->update( $self->result_source, \%to_update, $self->_storage_ident_condition ); if ($rows == 0) { @@ -611,7 +611,7 @@ sub delete { if (ref $self) { $self->throw_exception( "Not in database" ) unless $self->in_storage; - $self->result_source->storage->delete( + $self->result_source->schema->storage->delete( $self->result_source, $self->_storage_ident_condition ); @@ -1192,7 +1192,7 @@ sub copy { foreign_alias => "\xFF", # irrelevant, )->{inferred_values} - ) for $self->search_related($rel_name)->all; + ) for $self->related_resultset($rel_name)->all; } return $new; } @@ -1356,7 +1356,10 @@ Alias for L =cut -sub insert_or_update { shift->update_or_insert(@_) } +sub insert_or_update { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->update_or_insert(@_); +} sub update_or_insert { my $self = shift; diff --git a/lib/DBIx/Class/SQLMaker/LimitDialects.pm b/lib/DBIx/Class/SQLMaker/LimitDialects.pm index e6132d6..89e63e0 100644 --- a/lib/DBIx/Class/SQLMaker/LimitDialects.pm +++ b/lib/DBIx/Class/SQLMaker/LimitDialects.pm @@ -275,7 +275,7 @@ EOS if ( $rs_attrs->{order_by} and - $rs_attrs->{result_source}->storage->_order_by_is_stable( + $rs_attrs->{result_source}->schema->storage->_order_by_is_stable( @{$rs_attrs}{qw/from order_by where/} ) ) { @@ -540,7 +540,7 @@ sub _GenericSubQ { . 'main-table-based order criteria.' ) unless $rs_attrs->{order_by}; - my $usable_order_colinfo = $main_rsrc->storage->_extract_colinfo_of_stable_main_source_order_by_portion( + my $usable_order_colinfo = $main_rsrc->schema->storage->_extract_colinfo_of_stable_main_source_order_by_portion( $rs_attrs ); diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 04f92cc..c0cba10 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -12,17 +12,17 @@ use Scalar::Util qw/weaken blessed/; use DBIx::Class::_Util qw( refcount quote_sub scope_guard is_exception dbic_internal_try + fail_on_internal_call ); use Devel::GlobalDestruction; use namespace::clean; -__PACKAGE__->mk_classdata('class_mappings' => {}); -__PACKAGE__->mk_classdata('source_registrations' => {}); -__PACKAGE__->mk_classdata('storage_type' => '::DBI'); -__PACKAGE__->mk_classdata('storage'); -__PACKAGE__->mk_classdata('exception_action'); -__PACKAGE__->mk_classdata('stacktrace' => $ENV{DBIC_TRACE} || 0); -__PACKAGE__->mk_classdata('default_resultset_attributes' => {}); +__PACKAGE__->mk_group_accessors( inherited => qw( storage exception_action ) ); +__PACKAGE__->mk_classaccessor('class_mappings' => {}); +__PACKAGE__->mk_classaccessor('source_registrations' => {}); +__PACKAGE__->mk_classaccessor('storage_type' => '::DBI'); +__PACKAGE__->mk_classaccessor('stacktrace' => $ENV{DBIC_TRACE} || 0); +__PACKAGE__->mk_classaccessor('default_resultset_attributes' => {}); =head1 NAME @@ -525,7 +525,10 @@ version, overload L instead. =cut -sub connect { shift->clone->connection(@_) } +sub connect { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->clone->connection(@_); +} =head2 resultset @@ -769,6 +772,8 @@ those values. =cut sub populate { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + my ($self, $name, $data) = @_; my $rs = $self->resultset($name) or $self->throw_exception("'$name' is not a resultset"); @@ -1517,8 +1522,8 @@ sub compose_connection { my $source = $self->source($source_name); my $class = $source->result_class; $self->inject_base($class, 'DBIx::Class::ResultSetProxy'); - $class->mk_classdata(resultset_instance => $source->resultset); - $class->mk_classdata(class_resolver => $self); + $class->mk_classaccessor(resultset_instance => $source->resultset); + $class->mk_classaccessor(class_resolver => $self); } $self->connection(@info); return $self; @@ -1532,9 +1537,9 @@ sub compose_connection { my $source = $schema->source($source_name); my $class = $source->result_class; #warn "$source_name $class $source ".$source->storage; - $class->mk_classdata(result_source_instance => $source); - $class->mk_classdata(resultset_instance => $source->resultset); - $class->mk_classdata(class_resolver => $schema); + $class->mk_classaccessor(result_source_instance => $source); + $class->mk_classaccessor(resultset_instance => $source->resultset); + $class->mk_classaccessor(class_resolver => $schema); } return $schema; } diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 013cbc4..8101f2e 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -26,7 +26,7 @@ __PACKAGE__->add_columns 'size' => '20' }, ); -__PACKAGE__->set_primary_key('version'); +__PACKAGE__->result_source_instance->set_primary_key('version'); package # Hide from PAUSE DBIx::Class::Version::TableCompat; @@ -41,7 +41,7 @@ __PACKAGE__->add_columns 'data_type' => 'VARCHAR', }, ); -__PACKAGE__->set_primary_key('Version'); +__PACKAGE__->result_source_instance->set_primary_key('Version'); package # Hide from PAUSE DBIx::Class::Version; @@ -206,11 +206,13 @@ use DBIx::Class::_Util 'dbic_internal_try'; use Scalar::Util 'weaken'; use namespace::clean; -__PACKAGE__->mk_classdata('_filedata'); -__PACKAGE__->mk_classdata('upgrade_directory'); -__PACKAGE__->mk_classdata('backup_directory'); -__PACKAGE__->mk_classdata('do_backup'); -__PACKAGE__->mk_classdata('do_diff_on_init'); +__PACKAGE__->mk_group_accessors( inherited => qw( + _filedata + upgrade_directory + backup_directory + do_backup + do_diff_on_init +) ); =head1 METHODS @@ -591,7 +593,7 @@ sub _on_connect weaken (my $w_storage = $self->storage ); - $self->{vschema} = DBIx::Class::Version->connect( + $self->{vschema} = DBIx::Class::Version->clone->connection( sub { $w_storage->dbh }, # proxy some flags from the main storage @@ -606,7 +608,7 @@ sub _on_connect # check for legacy versions table and move to new if exists unless ($self->_source_exists($vtable)) { - my $vtable_compat = DBIx::Class::VersionCompat->connect(sub { $w_storage->dbh })->resultset('TableCompat'); + my $vtable_compat = DBIx::Class::VersionCompat->clone->connection(sub { $w_storage->dbh })->resultset('TableCompat'); if ($self->_source_exists($vtable_compat)) { $self->{vschema}->deploy; map { $vtable->new_result({ installed => $_->Installed, version => $_->Version })->insert } $vtable_compat->all; diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index f512843..d949b01 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -16,7 +16,7 @@ use DBIx::Class::Carp; use DBIx::Class::Storage::BlockRunner; use Scalar::Util qw/blessed weaken/; use DBIx::Class::Storage::TxnScopeGuard; -use DBIx::Class::_Util 'dbic_internal_try'; +use DBIx::Class::_Util qw( dbic_internal_try fail_on_internal_call ); use Try::Tiny; use namespace::clean; @@ -25,7 +25,10 @@ __PACKAGE__->mk_group_accessors(component_class => 'cursor_class'); __PACKAGE__->cursor_class('DBIx::Class::Cursor'); -sub cursor { shift->cursor_class(@_); } +sub cursor { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->cursor_class(@_); +} =head1 NAME diff --git a/lib/DBIx/Class/UTF8Columns.pm b/lib/DBIx/Class/UTF8Columns.pm index 793c1bc..38a4dd4 100644 --- a/lib/DBIx/Class/UTF8Columns.pm +++ b/lib/DBIx/Class/UTF8Columns.pm @@ -3,7 +3,7 @@ use strict; use warnings; use base qw/DBIx::Class/; -__PACKAGE__->mk_classdata( '_utf8_columns' ); +__PACKAGE__->mk_group_accessors( inherited => '_utf8_columns' ); =head1 NAME @@ -94,7 +94,7 @@ sub utf8_columns { if (@_) { foreach my $col (@_) { $self->throw_exception("column $col doesn't exist") - unless $self->has_column($col); + unless $self->result_source_instance->has_column($col); } return $self->_utf8_columns({ map { $_ => 1 } @_ }); } else { diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index f64e04b..3f60d3f 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -577,7 +577,7 @@ sub fail_on_internal_call { $fr = [ CORE::caller(1) ]; $argdesc = ref $DB::args[0] ? DBIx::Class::_Util::refdesc($DB::args[0]) - : undef + : ( $DB::args[0] . '' ) ; }; @@ -589,7 +589,7 @@ sub fail_on_internal_call { $fr->[1] !~ /\b(?:CDBICompat|ResultSetProxy)\b/ # no point touching there ) { DBIx::Class::Exception->throw( sprintf ( - "Illegal internal call of indirect proxy-method %s() with argument %s: examine the last lines of the proxy method deparse below to determine what to call directly instead at %s on line %d\n\n%s\n\n Stacktrace starts", + "Illegal internal call of indirect proxy-method %s() with argument '%s': examine the last lines of the proxy method deparse below to determine what to call directly instead at %s on line %d\n\n%s\n\n Stacktrace starts", $fr->[3], $argdesc, @{$fr}[1,2], ( $fr->[6] || do { require B::Deparse; no strict 'refs'; diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index 95a460f..b8159c4 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -33,7 +33,7 @@ is(Film->__driver, "SQLite", "Driver set correctly"); } eval { my $duh = Film->insert; }; -like $@, qr/Result object instantiation requires a hashref as argument/, "needs a hashref"; +like $@, qr/Result object instantiation requires a single hashref argument/, "needs a hashref"; ok +Film->create_test_film; diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index bac11ed..c063657 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -50,7 +50,7 @@ eval { my $pj = Film->add_to_actors(\%pj_data) }; like $@, qr/class/, "add_to_actors must be object method"; eval { my $pj = $btaste->add_to_actors(%pj_data) }; -like $@, qr/Result object instantiation requires a hashref as argument/, "add_to_actors takes hash"; +like $@, qr/Result object instantiation requires a single hashref argument/, "add_to_actors takes hash"; ok( my $pj = $btaste->add_to_actors(