[Bast-commits] r9308 - in DBIx-Class/0.08/trunk: lib/DBIx/Class
t/resultset
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed May 5 11:01:35 GMT 2010
Author: ribasushi
Date: 2010-05-05 12:01:35 +0100 (Wed, 05 May 2010)
New Revision: 9308
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/trunk/t/resultset/as_subselect_rs.t
Log:
Changes
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2010-05-05 09:52:30 UTC (rev 9307)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2010-05-05 11:01:35 UTC (rev 9308)
@@ -1289,11 +1289,6 @@
$sub_attrs->{select} = @pcols ? \@pcols : [ 1 ];
}
-
- # this is so that the query can be simplified e.g.
- # * ordering can be thrown away in things like Top limit
- $sub_attrs->{-for_count_only} = 1;
-
return $rsrc->resultset_class
->new ($rsrc, $sub_attrs)
->as_subselect_rs
@@ -2684,15 +2679,22 @@
my $attrs = $self->_resolved_attrs;
- return $self->result_source->resultset->search( undef, {
+ my $fresh_rs = (ref $self)->new (
+ $self->result_source
+ );
+
+ # these pieces will be locked in the subquery
+ delete $fresh_rs->{cond};
+ delete @{$fresh_rs->{attrs}}{qw/where bind/};
+
+ return $fresh_rs->search( {}, {
from => [{
$attrs->{alias} => $self->as_query,
-alias => $attrs->{alias},
-source_handle => $self->result_source->handle,
}],
- map { $_ => $attrs->{$_} } qw/select as alias/
-
- });
+ alias => $attrs->{alias},
+ });
}
# This code is called by search_related, and makes sure there
Modified: DBIx-Class/0.08/trunk/t/resultset/as_subselect_rs.t
===================================================================
--- DBIx-Class/0.08/trunk/t/resultset/as_subselect_rs.t 2010-05-05 09:52:30 UTC (rev 9307)
+++ DBIx-Class/0.08/trunk/t/resultset/as_subselect_rs.t 2010-05-05 11:01:35 UTC (rev 9308)
@@ -22,4 +22,21 @@
'... and chaining off the virtual view works';
dies_ok { $new_rs->as_subselect_rs->search({'artwork_to_artist.artwork_cd_id'=> 1})->count }
q{... but chaining off of a virtual view using join doesn't work};
+
+my $book_rs = $schema->resultset ('BooksInLibrary')->search ({}, { join => 'owner' });
+
+is_same_sql_bind (
+ $book_rs->as_subselect_rs->as_query,
+ '(SELECT me.id, me.source, me.owner, me.title, me.price
+ FROM (
+ SELECT me.id, me.source, me.owner, me.title, me.price
+ FROM books me
+ JOIN owners owner ON owner.id = me.owner
+ WHERE ( source = ? )
+ ) me
+ )',
+ [ [ source => 'Library' ] ],
+ 'Resultset-class attributes do not seep outside of the subselect',
+);
+
done_testing;
More information about the Bast-commits
mailing list