like the rest of DBIC
- DBIC::FilterColumn "from_storage" handler is now invoked on NULLs
returned from storage
+ - Custom condition relationships are now invoked with a slightly
+ different signature (existing coderefs will continue to work)
* Fixes
- Fix Resultset delete/update affecting *THE ENTIRE TABLE* in cases
metadata. Currently the supplied coderef is executed as:
$relationship_info->{cond}->({
- self_alias => The alias of the invoking resultset ('me' in case of a result object),
- foreign_alias => The alias of the to-be-joined resultset (often matches relname),
- self_resultsource => The invocant's resultsource,
- foreign_relname => The relationship name (does *not* always match foreign_alias),
- self_rowobj => The invocant itself in case of a $result_object->$relationship call
+ self_resultsource => The resultsource instance on which rel_name is registered
+ rel_name => The relationship name (does *NOT* always match foreign_alias)
+
+ self_alias => The alias of the invoking resultset
+ foreign_alias => The alias of the to-be-joined resultset (does *NOT* always match rel_name)
+
+ self_resultobj => The invocant object itself in case of a $resultobj->$rel_name() call
+
+ # deprecated inconsistent names, will be forever available for legacy code
+ self_rowobj => Old deprecated slot for self_resultobj
+ foreign_relname => Old deprecated slot for rel_name
});
=head3 attributes
foreach my $rel (@rels) {
next unless ref $data->[$index]->{$rel} eq "HASH";
my $result = $self->related_resultset($rel)->create($data->[$index]->{$rel});
- my ($reverse_relname, $reverse_relinfo) = %{$rsrc->reverse_relationship_info($rel)};
+ my (undef, $reverse_relinfo) = %{$rsrc->reverse_relationship_info($rel)};
my $related = $result->result_source->_resolve_condition(
$reverse_relinfo->{cond},
$self,
if (ref $args->{condition} eq 'CODE') {
- my ($crosstable_cond, $joinfree_cond) = $args->{condition}->({
+ my $cref_args = {
+ rel_name => $args->{rel_name},
+ self_resultsource => $self,
self_alias => $args->{self_alias},
foreign_alias => $args->{foreign_alias},
- self_resultsource => $self,
- foreign_relname => $args->{rel_name},
- self_rowobj => defined $args->{self_resultobj} ? $args->{self_resultobj} : undef,
- });
+ self_resultobj => defined $args->{self_resultobj} ? $args->{self_resultobj} : undef,
+ };
+
+ # legacy - never remove these!!!
+ $cref_args->{foreign_relname} = $cref_args->{rel_name};
+ $cref_args->{self_rowobj} = $cref_args->{self_resultobj};
+
+ my ($crosstable_cond, $joinfree_cond) = $args->{condition}->($cref_args);
my @nonvalue_cols;
if ($joinfree_cond) {
# FIXME sanity check until things stabilize, remove at some point
$self->throw_exception (
- "A join-free condition returned for relationship '$args->{rel_name}' without a row-object to chain from"
+ "A join-free condition returned for relationship '$args->{rel_name}' without a result object to chain from"
) unless defined $args->{self_resultobj};
my $foreign_src_fq_col_list = { map { ( "$args->{foreign_alias}.$_" => 1 ) } $self->related_source($args->{rel_name})->columns };
use Config;
use Carp 'confess';
-use Scalar::Util 'blessed';
+use Scalar::Util qw(blessed refaddr);
use base 'Exporter';
our @EXPORT_OK = qw(local_umask stacktrace check_customcond_args);
confess "Expecting a hashref"
unless ref $args eq 'HASH';
- for (qw(foreign_relname self_alias foreign_alias)) {
+ for (qw(rel_name foreign_relname self_alias foreign_alias)) {
confess "Custom condition argument '$_' must be a plain string"
if length ref $args->{$_} or ! length $args->{$_};
}
+ confess "Current and legacy rel_name arguments do not match"
+ if $args->{rel_name} ne $args->{foreign_relname};
+
confess "Custom condition argument 'self_resultsource' must be a rsrc instance"
unless defined blessed $args->{self_resultsource} and $args->{self_resultsource}->isa('DBIx::Class::ResultSource');
confess "Passed resultsource has no record of the supplied rel_name - likely wrong \$rsrc"
- unless ref $args->{self_resultsource}->relationship_info($args->{foreign_relname});
+ unless ref $args->{self_resultsource}->relationship_info($args->{rel_name});
+
+ if (defined $args->{self_resultobj} or defined $args->{self_rowobj} ) {
+ for (qw(self_resultobj self_rowobj)) {
+ confess "Custom condition argument '$_' must be a result instance"
+ unless defined blessed $args->{$_} and $args->{$_}->isa('DBIx::Class::Row');
+ }
- if (defined $args->{self_rowobj}) {
- confess "Custom condition argument 'self_rowobj' must be a result instance"
- unless defined blessed $args->{self_rowobj} and $args->{self_rowobj}->isa('DBIx::Class::Row');
+ confess "Current and legacy self_resultobj arguments do not match"
+ if refaddr($args->{self_resultobj}) != refaddr($args->{self_rowobj});
}
$args;