}
my $rs = (ref $self)->new($self->result_source, $attrs);
- $rs->{_parent_rs} = $self->{_parent_rs} if ($self->{_parent_rs});
+ $rs->{_parent_rs} = $self->{_parent_rs} if ($self->{_parent_rs}); #XXX - hack to pass through parent of related resultsets
unless (@_) { # no search, effectively just a clone
my $rows = $self->get_cache;
# Add the ResultSet's alias
foreach my $key (grep { ! m/\./ } keys %$unique_query) {
- # TODO: tidy up alias shit
- my $alias = $self->{attrs}{alias} || 'me';
+ my $alias = $self->{attrs}->{alias};
$unique_query->{"$alias.$key"} = delete $unique_query->{$key};
}
sub _resolve {
my $self = shift;
+ return if(exists $self->{_attrs}); #return if _resolve has already been called
+
my $attrs = $self->{attrs};
my $source = ($self->{_parent_rs}) ? $self->{_parent_rs} : $self->{result_source};
sub reset {
my ($self) = @_;
+ delete $self->{_attrs} if (exists $self->{_attrs});
+
$self->{all_cache_position} = 0;
$self->cursor->reset;
return $self;
my ($self) = @_;
my $del = {};
- # this is broken now
my $cond = $self->_cond_for_update_delete;
$self->result_source->storage->delete($self->result_source->from, $cond);
$self->{related_resultsets} ||= {};
return $self->{related_resultsets}{$rel} ||= do {
-# warn "fetching related resultset for rel '$rel' " . $self->result_source->{name};
+ #warn "fetching related resultset for rel '$rel' " . $self->result_source->{name};
my $rel_obj = $self->result_source->relationship_info($rel);
$self->throw_exception(
"search_related: result source '" . $self->result_source->name .
join => $rel,
_live_join => $rel }
);
+
+ # keep reference of the original resultset
$rs->{_parent_rs} = $self->result_source;
return $rs;
};