quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel ), @qsub_args;
DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and DBIx::Class::_Util::fail_on_internal_call;
- DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = DBIx::Class::_Util::fail_on_internal_wantarray;
shift->related_resultset(%s)->search( @_ )
EOC
use SQL::Abstract 'is_literal_value';
use DBIx::Class::_Util qw(
dbic_internal_try dbic_internal_catch dump_value emit_loud_diag
- fail_on_internal_wantarray fail_on_internal_call
- UNRESOLVABLE_CONDITION DUMMY_ALIASPAIR
+ fail_on_internal_call UNRESOLVABLE_CONDITION DUMMY_ALIASPAIR
);
use DBIx::Class::SQLMaker::Util qw( normalize_sqla_condition extract_equality_conditions );
use DBIx::Class::ResultSource::FromSpec::Util 'find_join_path_to_alias';
=cut
sub search {
- my $self = shift;
- my $rs = $self->search_rs( @_ );
+ my $rs = shift->search_rs( @_ );
- if (wantarray) {
- DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = fail_on_internal_wantarray;
- return $rs->all;
- }
- elsif (defined wantarray) {
- return $rs;
- }
- else {
- # we can be called by a relationship helper, which in
- # turn may be called in void context due to some braindead
- # overload or whatever else the user decided to be clever
- # at this particular day. Thus limit the exception to
- # external code calls only
- $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense')
- if (caller)[0] !~ /^\QDBIx::Class::/;
-
- return ();
- }
+ return $rs->all
+ if wantarray;
+
+ return $rs
+ if defined wantarray;
+
+ # we can be called by a relationship helper, which in
+ # turn may be called in void context due to some braindead
+ # overload or whatever else the user decided to be clever
+ # at this particular day. Thus limit the exception to
+ # external code calls only
+ $rs->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense')
+ if (caller)[0] !~ /^\QDBIx::Class::/;
+
+ # we are in void ctx here, but just in case
+ return ();
}
=head2 search_rs
=cut
-sub search_literal {
+sub search_literal :DBIC_method_is_indirect_sugar {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
+
my ($self, $sql, @bind) = @_;
my $attr;
if ( @bind && ref($bind[-1]) eq 'HASH' ) {
=cut
-sub search_like {
+sub search_like :DBIC_method_is_indirect_sugar {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
+
my $class = shift;
carp_unique (
'search_like() is deprecated and will be removed in DBIC version 0.09.'
=cut
-sub slice {
+sub slice :DBIC_method_is_indirect_sugar {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
+
my ($self, $min, $max) = @_;
my $attrs = {}; # = { %{ $self->{attrs} || {} } };
$attrs->{offset} = $self->{attrs}{offset} || 0;
'Starting with DBIC@0.082900 as_subselect_rs() always returns a ResultSet '
. 'instance regardless of calling context. Please force scalar() context to '
. 'silence this warning'
- )
- and
- DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY
- and
- my $sog = fail_on_internal_wantarray
- ;
+ );
my $self = shift;
use base 'DBIx::Class';
use DBIx::Class::Carp;
-use DBIx::Class::_Util qw( fail_on_internal_wantarray fail_on_internal_call );
+use DBIx::Class::_Util 'fail_on_internal_call';
use namespace::clean;
=head1 NAME
#my ($self,$function) = @_;
my $cursor = $_[0]->func_rs($_[1])->cursor;
- if( wantarray ) {
- DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = fail_on_internal_wantarray;
- return map { $_->[ 0 ] } $cursor->all;
- }
-
- return ( $cursor->next )[ 0 ];
+ wantarray
+ ? map { $_->[ 0 ] } $cursor->all
+ : ( $cursor->next )[ 0 ]
+ ;
}
=head2 func_rs
'Starting with DBIC@0.082900 func_rs() always returns a ResultSet '
. 'instance regardless of calling context. Please force scalar() context to '
. 'silence this warning'
- )
- and
- DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY
- and
- my $sog = fail_on_internal_wantarray
- ;
+ );
$rs->search_rs( undef, {
columns => { $self->{_as} => { $function => $select } }
{ substr($_, 5) => !!( $ENV{$_} ) }
qw(
DBIC_SHUFFLE_UNORDERED_RESULTSETS
- DBIC_ASSERT_NO_INTERNAL_WANTARRAY
DBIC_ASSERT_NO_INTERNAL_INDIRECT_CALLS
DBIC_ASSERT_NO_ERRONEOUS_METAINSTANCE_USE
DBIC_ASSERT_NO_FAILING_SANITY_CHECKS
use base 'Exporter';
our @EXPORT_OK = qw(
- sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt
- fail_on_internal_wantarray fail_on_internal_call
+ sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt fail_on_internal_call
refdesc refcount hrefaddr set_subname get_subname describe_class_methods
scope_guard detected_reinvoked_destructor emit_loud_diag
true false
}
-{
- my $list_ctx_ok_stack_marker;
-
- sub fail_on_internal_wantarray () {
- return if $list_ctx_ok_stack_marker;
-
- if (! defined wantarray) {
- croak('fail_on_internal_wantarray() needs a tempvar to save the stack marker guard');
- }
-
- my $cf = 1;
- while ( ( (CORE::caller($cf+1))[3] || '' ) =~ / :: (?:
-
- # these are public API parts that alter behavior on wantarray
- search | search_related | slice | search_literal
-
- |
-
- # these are explicitly prefixed, since we only recognize them as valid
- # escapes when they come from the guts of CDBICompat
- CDBICompat .*? :: (?: search_where | retrieve_from_sql | retrieve_all )
-
- ) $/x ) {
- $cf++;
- }
-
- my ($fr, $want, $argdesc);
- {
- package DB;
- $fr = [ CORE::caller($cf) ];
- $want = ( CORE::caller($cf-1) )[5];
- $argdesc = ref $DB::args[0]
- ? DBIx::Class::_Util::refdesc($DB::args[0])
- : 'non '
- ;
- };
-
- if (
- $want and $fr->[0] =~ /^(?:DBIx::Class|DBICx::)/
- ) {
- DBIx::Class::Exception->throw( sprintf (
- "Improper use of %s instance in list context at %s line %d\n\n Stacktrace starts",
- $argdesc, @{$fr}[1,2]
- ), 'with_stacktrace');
- }
-
- weaken( $list_ctx_ok_stack_marker = my $mark = [] );
-
- $mark;
- }
-}
-
sub fail_on_internal_call {
my $fr = [ CORE::caller(1) ];