$where ||= $self->where();
$set ||= $self->set();
my $resultset = $self->schema->resultset($rs);
- $resultset = $resultset->search( ($where||{}) );
+ $resultset = $resultset->search_rs( $where )
+ if $where;
my $count = $resultset->count();
print "This action will modify $count ".ref($resultset)." records.\n" if (!$self->quiet);
$where ||= $self->where();
$attrs ||= $self->attrs();
my $resultset = $self->schema->resultset($rs);
- $resultset = $resultset->search( ($where||{}), ($attrs||()) );
+ $resultset = $resultset->search_rs( ($where||{}), ($attrs||()) )
+ if $where or $attrs;
my $count = $resultset->count();
print "This action will delete $count ".ref($resultset)." records.\n" if (!$self->quiet);
$where ||= $self->where();
$attrs ||= $self->attrs();
my $resultset = $self->schema->resultset($rs);
- $resultset = $resultset->search( ($where||{}), ($attrs||()) );
+ $resultset = $resultset->search_rs( ($where||{}), ($attrs||()) )
+ if $where or $attrs;
my @data;
my @columns = $resultset->result_source->columns();
sub resultset_instance {
my $self = shift;
- my $rs = $self->next::method(@_);
- $rs = $rs->search(undef, { columns => [ $self->columns('Essential') ] });
- return $rs;
+ $self->next::method(@_)
+ ->search_rs(undef, { columns => [ $self->columns('Essential') ] });
}
my $self = shift;
my $position_column = $self->position_column;
- my $psib = $self->previous_siblings->search(
+ my $psib = $self->previous_siblings->search_rs(
{},
{ rows => 1, order_by => { '-desc' => $position_column } },
)->single;
my $self = shift;
my $position_column = $self->position_column;
- my $fsib = $self->previous_siblings->search(
+ my $fsib = $self->previous_siblings->search_rs(
{},
{ rows => 1, order_by => { '-asc' => $position_column } },
)->single;
sub next_sibling {
my $self = shift;
my $position_column = $self->position_column;
- my $nsib = $self->next_siblings->search(
+ my $nsib = $self->next_siblings->search_rs(
{},
{ rows => 1, order_by => { '-asc' => $position_column } },
)->single;
sub last_sibling {
my $self = shift;
my $position_column = $self->position_column;
- my $lsib = $self->next_siblings->search(
+ my $lsib = $self->next_siblings->search_rs(
{},
{ rows => 1, order_by => { '-desc' => $position_column } },
)->single;
my $self = shift;
my $position_column = $self->position_column;
- my $cursor = $self->next_siblings->search(
+ my $cursor = $self->next_siblings->search_rs(
{},
{ rows => 1, order_by => { '-desc' => $position_column }, select => $position_column },
)->cursor;
$self->store_column(
$position_column,
( $rsrc->resultset
- ->search($self->_storage_ident_condition, { rows => 1, columns => $position_column })
+ ->search_rs($self->_storage_ident_condition, { rows => 1, columns => $position_column })
->cursor
->next
)[0] || $self->throw_exception(
$ord = 'desc';
}
- my $shift_rs = $self->_group_rs-> search ({ $position_column => { -between => \@between } });
+ my $shift_rs = $self->_group_rs-> search_rs ({ $position_column => { -between => \@between } });
# some databases (sqlite, pg, perhaps others) are dumb and can not do a
# blanket increment/decrement without violating a unique constraint.
) {
my $clean_rs = $rsrc->resultset;
- for ( $shift_rs->search (
+ for ( $shift_rs->search_rs (
{}, { order_by => { "-$ord", $position_column }, select => [$position_column, @pcols] }
)->cursor->all ) {
my $pos = shift @$_;
if( defined $jfc ) {
- $rel_rset = $rsrc->related_source($rel)->resultset->search(
+ $rel_rset = $rsrc->related_source($rel)->resultset->search_rs(
$jfc,
$rel_info->{attrs},
);
my $obj_table_alias = lc($rsrc->source_name) . '__row';
$obj_table_alias =~ s/\W+/_/g;
- $rel_rset = $rsrc->resultset->search(
+ $rel_rset = $rsrc->resultset->search_rs(
$self->ident_condition($obj_table_alias),
{ alias => $obj_table_alias },
- )->related_resultset('me')->search(undef, $rel_info->{attrs})
+ )->related_resultset('me')->search_rs(undef, $rel_info->{attrs})
}
else {
: weaken( $attrs->{related_objects}{$_} = $self )
for keys %$reverse;
- $rel_rset = $rsrc->related_source($rel)->resultset->search(
+ $rel_rset = $rsrc->related_source($rel)->resultset->search_rs(
UNRESOLVABLE_CONDITION, # guards potential use of the $rs in the future
$attrs,
);
=cut
-sub search {
+sub search :DBIC_method_is_indirect_sugar {
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
+
my $rs = shift->search_rs( @_ );
return $rs->all
}
# Run the query, passing the result_class since it should propagate for find
- my $rs = $self->search ($final_cond, {result_class => $self->result_class, %$attrs});
+ my $rs = $self->search_rs( $final_cond, {result_class => $self->result_class, %$attrs} );
if ($rs->_resolved_attrs->{collapse}) {
my $row = $rs->next;
carp "Query returned more than one row" if $rs->next;
sub count {
my $self = shift;
- return $self->search(@_)->count if @_ and defined $_[0];
+ return $self->search_rs(@_)->count if @_ and defined $_[0];
return scalar @{ $self->get_cache } if $self->get_cache;
my $attrs = { %{ $self->_resolved_attrs } };
sub count_rs {
my $self = shift;
- return $self->search(@_)->count_rs if @_;
+ return $self->search_rs(@_)->count_rs if @_;
# this may look like a lack of abstraction (count() does about the same)
# but in fact an _rs *must* use a subquery for the limits, as the
return $rsrc->resultset_class
->new ($rsrc, $sub_attrs)
->as_subselect_rs
- ->search ({}, { columns => { count => $rsrc->schema->storage->_count_select ($rsrc, $attrs) } })
+ ->search_rs ({}, { columns => { count => $rsrc->schema->storage->_count_select ($rsrc, $attrs) } })
->get_column ('count');
}
}
}
- $subrs = $subrs->search({}, { group_by => $attrs->{columns} });
+ $subrs = $subrs->search_rs({}, { group_by => $attrs->{columns} });
}
$guard = $storage->txn_scope_guard;
}
- $colinfo->{$rel}{rs}->search({ map # only so that we inherit them values properly, no actual search
+ $colinfo->{$rel}{rs}->search_rs({ map # only so that we inherit them values properly, no actual search
{
$_ => { '=' =>
- ( $main_proto_rs ||= $rsrc->resultset->search($main_proto) )
+ ( $main_proto_rs ||= $rsrc->resultset->search_rs($main_proto) )
->get_column( $colinfo->{$rel}{fk_map}{$_} )
->as_query
}
# Nuke the prefetch (if any) before the new $rs attrs
# are resolved (prefetch is useless - we are wrapping
# a subquery anyway).
- my $rs_copy = $self->search;
+ my $rs_copy = $self->search_rs;
$rs_copy->{attrs}{join} = $self->_merge_joinpref_attr (
$rs_copy->{attrs}{join},
delete $rs_copy->{attrs}{prefetch},
}
}
- $self->{_parent_resultset}->search(undef, {
+ $self->{_parent_resultset}->search_rs(undef, {
columns => { $self->{_as} => $select }
});
};
=cut
sub get_from_storage {
- my $self = shift @_;
- my $attrs = shift @_;
- my $resultset = $self->result_source->resultset;
+ my $self = shift;
- if(defined $attrs) {
- $resultset = $resultset->search(undef, $attrs);
- }
-
- return $resultset->find($self->_storage_ident_condition);
+ # with or without attrs?
+ (
+ defined( $_[0] )
+ ? $self->result_source->resultset->search_rs( undef, $_[0] )
+ : $self->result_source->resultset
+ )->find(
+ $self->_storage_ident_condition
+ );
}
=head2 discard_changes
my $vtable = $self->{vschema}->resultset('Table');
my $version = dbic_internal_try {
- $vtable->search({}, { order_by => { -desc => 'installed' }, rows => 1 } )
+ $vtable->search_rs({}, { order_by => { -desc => 'installed' }, rows => 1 } )
->get_column ('version')
->next;
};
my ($self, $rs) = @_;
( dbic_internal_try {
- $rs->search( UNRESOLVABLE_CONDITION )->cursor->next;
+ $rs->search_rs( UNRESOLVABLE_CONDITION )->cursor->next;
1;
} )
? 1
@fr2 = CORE::caller(@fr2 ? 3 : 2)
and
# if the frame that called us is an indirect itself - nothing to see here
- ! grep
+ (! grep
{ $_ eq 'DBIC_method_is_indirect_sugar' }
do {
no strict 'refs';
attributes::get( \&{ $fr2[3] })
}
+ )
+ and
+ (
+ $fr->[3] ne 'DBIx::Class::ResultSet::search'
+ or
+ # these are explicit wantarray-passthrough callsites for search() due to old silly API choice
+ $fr2[3] !~ /^DBIx::Class::Ordered::(?: _group_rs | (?: _ | next_ | previous_ )? siblings )/x
+ )
) {
my $argdesc;