# (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
svp_begin
svp_release
relname_to_table_alias
- _straight_join_to_node
_dbh_last_insert_id
_fix_bind_params
_default_dbi_connect_attributes
_use_typeless_placeholders
_supports_typeless_placeholders
_determine_supports_typeless_placeholders
+
+ _inner_join_to_node
);
for my $method (@unimplemented) {
# 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
--- /dev/null
+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;