# just forbid it right now.
my $rel_info = $self->result_source->relationship_info($rel);
if (ref $rel_info->{cond} eq 'CODE') {
- my ($cond, $ext) = $rel_info->{cond}->({ self_alias => 'me',
- foreign_alias => $rel,
- self_rowobj => $self
- });
+ my ($cond, $ext) = $rel_info->{cond}->({
+ self_alias => 'me',
+ foreign_alias => $rel,
+ self_rowobj => $self,
+ self_resultsource => $self->result_source,
+ foreign_relname => $rel,
+ });
$self->throw_exception("unable to set_from_related - no simplified condition available for '${rel}'")
unless $ext;
DBICTest::Schema::Artist;
use base qw/DBICTest::BaseResult/;
+use Carp qw/confess/;
__PACKAGE__->table('artist');
__PACKAGE__->source_info({
sub {
my $args = shift;
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
return (
{ "$args->{foreign_alias}.artist" => { '=' => { -ident => "$args->{self_alias}.artistid"} },
"$args->{foreign_alias}.year" => { '>' => 1979, '<' => 1990 },
cds_84 => 'DBICTest::Schema::CD',
sub {
my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
return (
{ "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
"$args->{foreign_alias}.year" => 1984,
cds_90s => 'DBICTest::Schema::CD',
sub {
my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
return (
{ "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
"$args->{foreign_alias}.year" => { '>' => 1989, '<' => 2000 },
DBICTest::Schema::Artwork;
use base qw/DBICTest::BaseResult/;
+use Carp qw/confess/;
__PACKAGE__->table('cd_artwork');
__PACKAGE__->add_columns(
# other test to manytomany
__PACKAGE__->has_many('artwork_to_artist_test_m2m', 'DBICTest::Schema::Artwork_to_Artist',
- sub {
- my $args = shift;
- return (
- { "$args->{foreign_alias}.artwork_cd_id" => { -ident => "$args->{self_alias}.cd_id" },
- },
- $args->{self_rowobj} && {
- "$args->{foreign_alias}.artwork_cd_id" => $args->{self_rowobj}->cd_id,
- }
- );
- });
+ sub {
+ my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
+ return (
+ { "$args->{foreign_alias}.artwork_cd_id" => { -ident => "$args->{self_alias}.cd_id" },
+ },
+ $args->{self_rowobj} && {
+ "$args->{foreign_alias}.artwork_cd_id" => $args->{self_rowobj}->cd_id,
+ }
+ );
+ }
+);
__PACKAGE__->many_to_many('artists_test_m2m2', 'artwork_to_artist_test_m2m', 'artist');
1;
DBICTest::Schema::Artwork_to_Artist;
use base qw/DBICTest::BaseResult/;
+use Carp qw/confess/;
__PACKAGE__->table('artwork_to_artist');
__PACKAGE__->add_columns(
__PACKAGE__->belongs_to('artist', 'DBICTest::Schema::Artist', 'artist_id');
__PACKAGE__->belongs_to('artist_test_m2m', 'DBICTest::Schema::Artist',
- sub {
- my $args = shift;
- return (
- { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
- "$args->{foreign_alias}.rank" => { '<' => 10 },
- },
- $args->{self_rowobj} && {
- "$args->{foreign_alias}.artistid" => $args->{self_rowobj}->artist_id,
- "$args->{foreign_alias}.rank" => { '<' => 10 },
- }
- );
- });
+ sub {
+ my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
+ return (
+ { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
+ "$args->{foreign_alias}.rank" => { '<' => 10 },
+ },
+ $args->{self_rowobj} && {
+ "$args->{foreign_alias}.artistid" => $args->{self_rowobj}->artist_id,
+ "$args->{foreign_alias}.rank" => { '<' => 10 },
+ }
+ );
+ }
+);
__PACKAGE__->belongs_to('artist_test_m2m_noopt', 'DBICTest::Schema::Artist',
- sub {
- my $args = shift;
- return (
- { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
- "$args->{foreign_alias}.rank" => { '<' => 10 },
- }
- );
- });
+ sub {
+ my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
+ return (
+ { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
+ "$args->{foreign_alias}.rank" => { '<' => 10 },
+ }
+ );
+ }
+);
1;
DBICTest::Schema::Track;
use base qw/DBICTest::BaseResult/;
+use Carp qw/confess/;
+
__PACKAGE__->load_components(qw/InflateColumn::DateTime Ordered/);
__PACKAGE__->table('track');
next_track => __PACKAGE__,
sub {
my $args = shift;
+
+ # This is for test purposes only. A regular user does not
+ # need to sanity check the passed-in arguments, this is what
+ # the tests are for :)
+ my @missing_args = grep { ! defined $args->{$_} }
+ qw/self_alias foreign_alias self_resultsource foreign_relname/;
+ confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
+ if @missing_args;
+
return (
{ "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
"$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },