[Rt-commit] r19065 - rt/3.999/branches/FTS/lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Mon Apr 6 16:54:01 EDT 2009
Author: ruz
Date: Mon Apr 6 16:54:01 2009
New Revision: 19065
Modified:
rt/3.999/branches/FTS/lib/RT/Collection.pm
Log:
* move caching of some aliases into RT::Collection
* add join_transactions method
Modified: rt/3.999/branches/FTS/lib/RT/Collection.pm
==============================================================================
--- rt/3.999/branches/FTS/lib/RT/Collection.pm (original)
+++ rt/3.999/branches/FTS/lib/RT/Collection.pm Mon Apr 6 16:54:01 2009
@@ -305,5 +305,35 @@
return $self->items_order_by( $self->SUPER::items_array_ref() );
}
+sub clean_slate {
+ my $self = shift;
+ $self->{'_sql_aliases'} = {};
+ return $self->SUPER::clean_slate(@_);
+}
+
+sub join_transactions {
+ my $self = shift;
+ my %args = ( new => 0, @_ );
+
+ return $self->{'_sql_aliases'}{'transactions'}
+ if !$args{'new'} && $self->{'_sql_aliases'}{'transactions'};
+
+ my $alias = $self->join(
+ alias1 => 'main',
+ column1 => 'id',
+ table2 => RT::Model::TransactionCollection->new,
+ column2 => 'object_id',
+ );
+ $self->limit(
+ leftjoin => $alias,
+ alias => $alias,
+ column => 'object_type',
+ value => ref $self->new_item,
+ );
+ $self->{'_sql_aliases'}{'transactions'} = $alias
+ unless $args{'new'};
+
+ return $alias;
+}
1;
More information about the Rt-commit
mailing list