[Bast-commits] r3955 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Sun Jan 20 12:28:56 GMT 2008
Author: matthewt
Date: 2008-01-20 12:28:55 +0000 (Sun, 20 Jan 2008)
New Revision: 3955
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/trunk/t/76joins.t
Log:
made search_rs smarter about when to preserve the cache to fix mm prefetch usage
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2008-01-18 13:03:08 UTC (rev 3954)
+++ DBIx-Class/0.08/trunk/Changes 2008-01-20 12:28:55 UTC (rev 3955)
@@ -1,5 +1,7 @@
Revision history for DBIx::Class
+ - Made search_rs smarter about when to preserve the cache to fix
+ mm prefetch usage
- Added Storage::DBI subclass for MSSQL over ODBC.
- Added freeze, thaw and dclone methods to Schema so that thawed
objects will get re-attached to the schema.
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2008-01-18 13:03:08 UTC (rev 3954)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2008-01-20 12:28:55 UTC (rev 3955)
@@ -11,6 +11,7 @@
use Storable;
use DBIx::Class::ResultSetColumn;
use DBIx::Class::ResultSourceHandle;
+use List::Util ();
use base qw/DBIx::Class/;
__PACKAGE__->mk_group_accessors('simple' => qw/result_class _source_handle/);
@@ -168,18 +169,26 @@
sub search_rs {
my $self = shift;
- my $rows;
-
- unless (@_) { # no search, effectively just a clone
- $rows = $self->get_cache;
- }
-
my $attrs = {};
$attrs = pop(@_) if @_ > 1 and ref $_[$#_] eq 'HASH';
my $our_attrs = { %{$self->{attrs}} };
my $having = delete $our_attrs->{having};
my $where = delete $our_attrs->{where};
+ my $rows;
+
+ my %safe = (alias => 1, cache => 1);
+
+ unless (
+ (@_ && defined($_[0])) # @_ == () or (undef)
+ ||
+ (keys %$attrs # empty attrs or only 'safe' attrs
+ && List::Util::first { !$safe{$_} } keys %$attrs)
+ ) {
+ # no search, effectively just a clone
+ $rows = $self->get_cache;
+ }
+
my $new_attrs = { %{$our_attrs}, %{$attrs} };
# merge new attrs into inherited
Modified: DBIx-Class/0.08/trunk/t/76joins.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76joins.t 2008-01-18 13:03:08 UTC (rev 3954)
+++ DBIx-Class/0.08/trunk/t/76joins.t 2008-01-20 12:28:55 UTC (rev 3955)
@@ -247,12 +247,8 @@
is($cd->producers->first->name, 'Matt S Trout', 'many_to_many accessor ok');
-TODO: {
- local $TODO = 'use prefetched values for many_to_many accessor';
+is($queries, 1, 'many_to_many accessor with nested prefetch ran exactly 1 query');
- is($queries, 1, 'many_to_many accessor with nested prefetch ran exactly 1 query');
-}
-
$queries = 0;
my $producers = $cd->search_related('cd_to_producer')->search_related('producer');
More information about the Bast-commits
mailing list