From: Peter Rabbitson Date: Sun, 5 Sep 2010 10:49:37 +0000 (+0200) Subject: Rename incorrectly named internal method (has nothing to do with MySQL) X-Git-Tag: v0.08124~81 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=31a8aaaf104a710ae5b7671659e89c1ef62c84e8;p=dbsrgits%2FDBIx-Class.git Rename incorrectly named internal method (has nothing to do with MySQL) Add an extra test (written due to a false-alarm) --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 2fa0717..5a88d57 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2555,7 +2555,7 @@ sub related_resultset { # (the select/as attrs were deleted in the beginning), we need to flip all # left joins to inner, so we get the expected results # read the comment on top of the actual function to see what this does - $attrs->{from} = $rsrc->schema->storage->_straight_join_to_node ($attrs->{from}, $alias); + $attrs->{from} = $rsrc->schema->storage->_inner_join_to_node ($attrs->{from}, $alias); #XXX - temp fix for result_class bug. There likely is a more elegant fix -groditi diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 46ad462..0511253 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -314,7 +314,6 @@ has 'write_handler' => ( svp_begin svp_release relname_to_table_alias - _straight_join_to_node _dbh_last_insert_id _fix_bind_params _default_dbi_connect_attributes @@ -392,6 +391,8 @@ my @unimplemented = qw( _use_typeless_placeholders _supports_typeless_placeholders _determine_supports_typeless_placeholders + + _inner_join_to_node ); for my $method (@unimplemented) { diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index 581ee2f..c46b0e3 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -421,7 +421,7 @@ sub _resolve_column_info { # the top of the stack, and if not - make sure the chain is inner-joined down # to the root. # -sub _straight_join_to_node { +sub _inner_join_to_node { my ($self, $from, $alias) = @_; # subqueries and other oddness are naturally not supported diff --git a/t/search/related_has_many.t b/t/search/related_has_many.t new file mode 100644 index 0000000..a359b4e --- /dev/null +++ b/t/search/related_has_many.t @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More; + +use lib qw(t/lib); +use DBIC::SqlMakerTest; +use DBICTest; + +my $schema = DBICTest->init_schema(); + +my $cd_rs = $schema->resultset('CD')->search ({ artist => { '!=', undef }}); + +# create some CDs without tracks +$cd_rs->create({ artist => 1, title => 'trackless_foo', year => 2010 }); +$cd_rs->create({ artist => 1, title => 'trackless_bar', year => 2010 }); + +my $tr_count = $schema->resultset('Track')->count; + +my $tr_rs = $cd_rs->search_related('tracks'); + + +my @tracks; +while ($tr_rs->next) { + push @tracks, $_; +} + +is (scalar @tracks, $tr_count, 'Iteration is correct'); +is ($tr_rs->count, $tr_count, 'Count is correct'); +is (scalar ($tr_rs->all), $tr_count, 'All is correct'); + +done_testing;