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 ();
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;
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
use base 'DBIx::Class';
-__PACKAGE__->mk_classdata('__AutoCommit');
+__PACKAGE__->mk_group_accessors( inherited => '__AutoCommit' );
sub set_column {
my $self = shift;
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,
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
}
sub new_related {
- return shift->search_related(shift)->new_result(shift);
+ return shift->search_related(shift)->new_result(@_);
}
=head1 FURTHER QUESTIONS?
=cut
-__PACKAGE__->mk_classdata('class_resolver' =>
+__PACKAGE__->mk_classaccessor('class_resolver' =>
'DBIx::Class::ClassResolver::PassThrough');
=begin hidden
my $class = shift;
my $schema = {};
bless $schema, 'DBIx::Class::Schema';
- $class->mk_classdata('schema_instance' => $schema);
+ $class->mk_classaccessor('schema_instance' => $schema);
}
=begin hidden
=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
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';
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;
}
sub _datetime_parser {
- shift->result_source->storage->datetime_parser (@_);
+ shift->result_source->schema->storage->datetime_parser (@_);
}
sub _post_inflate_datetime {
=cut
-__PACKAGE__->mk_classdata( 'position_column' => 'position' );
+__PACKAGE__->mk_classaccessor( 'position_column' => 'position' );
=head2 grouping_column
=cut
-__PACKAGE__->mk_classdata( 'grouping_column' );
+__PACKAGE__->mk_group_accessors( inherited => 'grouping_column' );
=head2 null_position_value
=cut
-__PACKAGE__->mk_classdata( 'null_position_value' => 0 );
+__PACKAGE__->mk_classaccessor( 'null_position_value' => 0 );
=head2 siblings
=cut
-__PACKAGE__->mk_classdata( '_initial_position_value' => 1 );
+__PACKAGE__->mk_classaccessor( '_initial_position_value' => 1 );
=head2 _next_position_value
$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;
}
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) = @_;
}
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 {
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
$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 {
=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
=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
=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
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,
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
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
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
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(@_);
}
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;
}
$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 {
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')
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";
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.');
}
# 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
# 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(
$_[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
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;
=cut
sub search_related {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
return shift->related_resultset(shift)->search(@_);
}
=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(@_);
}
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
);
};
}
}
- my $data = [ $self->result_source->storage->select_single(
+ my $data = [ $self->result_source->schema->storage->select_single(
$attrs->{from}, $attrs->{select},
$attrs->{where}, $attrs
)];
=cut
sub get_column {
- my ($self, $column) = @_;
- my $new = DBIx::Class::ResultSetColumn->new($self, $column);
- return $new;
+ DBIx::Class::ResultSetColumn->new(@_);
}
=head2 search_like
# 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');
}
# 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;
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');
}
=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
=cut
sub first {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
return $_[0]->reset->next;
}
# 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}) ];
};
### 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 {
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);
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
);
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
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
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
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
);
=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
=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
=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
=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
=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
=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
# 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) ];
}
}
=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');
));
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/;
result_class
/);
-__PACKAGE__->mk_classdata( sqlt_deploy_callback => 'default_sqlt_deploy_hook' );
+__PACKAGE__->mk_classaccessor( sqlt_deploy_callback => 'default_sqlt_deploy_hook' );
=head1 NAME
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}++;
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}++;
$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
=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
=cut
sub relationships {
- return keys %{shift->_relationships};
+ keys %{$_[0]->_relationships};
}
=head2 relationship_info
$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 ),
);
$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)
);
}
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)
);
=cut
-sub from { shift->name; }
+sub from { $_[0]->name }
=head1 FURTHER QUESTIONS?
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');
}
}
-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 {
# 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
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);
});
}
- $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);
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 );
$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;
$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) {
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
);
foreign_alias => "\xFF", # irrelevant,
)->{inferred_values}
- ) for $self->search_related($rel_name)->all;
+ ) for $self->related_resultset($rel_name)->all;
}
return $new;
}
=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;
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/}
)
) {
. '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
);
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
=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
=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");
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;
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;
}
'size' => '20'
},
);
-__PACKAGE__->set_primary_key('version');
+__PACKAGE__->result_source_instance->set_primary_key('version');
package # Hide from PAUSE
DBIx::Class::Version::TableCompat;
'data_type' => 'VARCHAR',
},
);
-__PACKAGE__->set_primary_key('Version');
+__PACKAGE__->result_source_instance->set_primary_key('Version');
package # Hide from PAUSE
DBIx::Class::Version;
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
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
# 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;
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;
__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
use warnings;
use base qw/DBIx::Class/;
-__PACKAGE__->mk_classdata( '_utf8_columns' );
+__PACKAGE__->mk_group_accessors( inherited => '_utf8_columns' );
=head1 NAME
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 {
$fr = [ CORE::caller(1) ];
$argdesc = ref $DB::args[0]
? DBIx::Class::_Util::refdesc($DB::args[0])
- : undef
+ : ( $DB::args[0] . '' )
;
};
$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';
}
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;
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(