##
## GOALS: We need to test the method for both void and array context for all
## the following relationship types: belongs_to, has_many. Additionally we
-## need to each each of those for both specified PK's and autogenerated PK's
+## need to test each of those for both specified PK's and autogenerated PK's
##
## Also need to test some stuff that should generate errors.
## ----------------------------------------------------------------------------
my $art_rs = $schema->resultset('Artist');
my $cd_rs = $schema->resultset('CD');
-my $restricted_art_rs = $art_rs->search({rank => 42});
+my $restricted_art_rs = $art_rs->search({ -and => [ rank => 42, charfield => { '=', \['(SELECT MAX(artistid) FROM artist) + ?', 6] } ] });
ok( $schema, 'Got a Schema object');
ok( $art_rs, 'Got Good Artist Resultset');
ARRAY_CONTEXT: {
## These first set of tests are cake because array context just delegates
- ## all it's processing to $resultset->create
+ ## all its processing to $resultset->create
HAS_MANY_NO_PKS: {
]);
## Did it use the condition in the resultset?
+ $more_crap->discard_changes;
cmp_ok( $more_crap->rank, '==', 42, "Got Correct rank for result object");
+ cmp_ok( $more_crap->charfield, '==', $more_crap->id + 5, "Got Correct charfield for result object");
}
}
})->first;
## Did it use the condition in the resultset?
+ $more_crap->discard_changes;
cmp_ok( $more_crap->rank, '==', 42, "Got Correct rank for result object");
+ cmp_ok( $more_crap->charfield, '==', $more_crap->id + 5, "Got Correct charfield for result object");
}
}
is $cooler->name, 'Cooler', 'Correct Name';
is $lamer->name, 'Lamer', 'Correct Name';
- cmp_ok $cooler->rank, '==', 42, 'Correct Rank';
+ for ($cooler, $lamer) {
+ $_->discard_changes;
+ cmp_ok( $_->rank, '==', 42, "Got Correct rank for result object");
+ cmp_ok( $_->charfield, '==', $_->id + 5, "Got Correct charfield for result object");
+ }
ARRAY_CONTEXT_WITH_COND_FROM_RS: {
]);
## Did it use the condition in the resultset?
+ $mega_lamer->discard_changes;
cmp_ok( $mega_lamer->rank, '==', 42, "Got Correct rank for result object");
+ cmp_ok( $mega_lamer->charfield, '==', $mega_lamer->id + 5, "Got Correct charfield for result object");
}
VOID_CONTEXT_WITH_COND_FROM_RS: {
## Did it use the condition in the resultset?
cmp_ok( $mega_lamer->rank, '==', 42, "Got Correct rank for result object");
+ cmp_ok( $mega_lamer->charfield, '==', $mega_lamer->id + 5, "Got Correct charfield for result object");
}
}