From: Peter Rabbitson Date: Sat, 12 Jul 2014 09:51:00 +0000 (+0200) Subject: Switch UNRESOLVABLE_CONDITION to an _Util constant X-Git-Tag: v0.082800~145 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=facd0e8e687648e52f29df73d62d9c993b9b19d1;p=dbsrgits%2FDBIx-Class.git Switch UNRESOLVABLE_CONDITION to an _Util constant --- diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 906307f..e2f6224 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -7,6 +7,7 @@ use base qw/DBIx::Class/; use Scalar::Util qw/weaken blessed/; use Try::Tiny; +use DBIx::Class::_Util 'UNRESOLVABLE_CONDITION'; use namespace::clean; =head1 NAME @@ -493,7 +494,7 @@ sub related_resultset { } catch { $self->throw_exception ($_) if $self->in_storage; - $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION; # RV, no return() + UNRESOLVABLE_CONDITION; # RV, no return() }; # keep in mind that the following if() block is part of a do{} - no return()s!!! @@ -522,7 +523,7 @@ sub related_resultset { # FIXME - this conditional doesn't seem correct - got to figure out # at some point what it does. Also the entire UNRESOLVABLE_CONDITION # business seems shady - we could simply not query *at all* - if ($cond eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) { + if ($cond eq UNRESOLVABLE_CONDITION) { my $reverse = $rsrc->reverse_relationship_info($rel); foreach my $rev_rel (keys %$reverse) { if ($reverse->{$rev_rel}{attrs}{accessor} && $reverse->{$rev_rel}{attrs}{accessor} eq 'multi') { diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 6f39723..f817d3a 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -7,7 +7,7 @@ use DBIx::Class::Carp; use DBIx::Class::ResultSetColumn; use Scalar::Util qw/blessed weaken reftype/; use DBIx::Class::_Util qw( - fail_on_internal_wantarray is_plain_value is_literal_value + fail_on_internal_wantarray is_plain_value is_literal_value UNRESOLVABLE_CONDITION ); use Try::Tiny; use Data::Compare (); # no imports!!! guard against insane architecture @@ -2492,7 +2492,7 @@ sub _merge_with_rscond { if (! defined $self->{cond}) { # just massage $data below } - elsif ($self->{cond} eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) { + elsif ($self->{cond} eq UNRESOLVABLE_CONDITION) { %new_data = %{ $self->{attrs}{related_objects} || {} }; # nothing might have been inserted yet @cols_from_relations = keys %new_data; } diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index ce88cbb..81ce7d8 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -9,7 +9,7 @@ use DBIx::Class::ResultSet; use DBIx::Class::ResultSourceHandle; use DBIx::Class::Carp; -use DBIx::Class::_Util 'is_literal_value'; +use DBIx::Class::_Util qw(is_literal_value UNRESOLVABLE_CONDITION); use Devel::GlobalDestruction; use Try::Tiny; use List::Util 'first'; @@ -1745,7 +1745,14 @@ sub _resolve_condition { return wantarray ? @res : $res[0]; } -our $UNRESOLVABLE_CONDITION = \ '1 = 0'; +# Keep this indefinitely. There is evidence of both CPAN and +# darkpan using it, and there isn't much harm in an extra var +# anyway. +our $UNRESOLVABLE_CONDITION = UNRESOLVABLE_CONDITION; +# YES I KNOW THIS IS EVIL +# it is there to save darkpan from themselves, since internally +# we are moving to a constant +Internals::SvREADONLY($UNRESOLVABLE_CONDITION => 1); # Resolves the passed condition to a concrete query fragment and a flag # indicating whether this is a cross-table condition. Also an optional @@ -1901,7 +1908,7 @@ sub _resolve_relationship_condition { $obj_cols->[$i], ) if $obj->in_storage; - return $UNRESOLVABLE_CONDITION; + return UNRESOLVABLE_CONDITION; } else { $cond->{"$plain_alias.$plain_cols->[$i]"} = $obj->get_column($obj_cols->[$i]); @@ -1913,7 +1920,7 @@ sub _resolve_relationship_condition { } elsif (ref $args->{condition} eq 'ARRAY') { if (@{$args->{condition}} == 0) { - return $UNRESOLVABLE_CONDITION; + return UNRESOLVABLE_CONDITION; } elsif (@{$args->{condition}} == 1) { return $self->_resolve_relationship_condition({ diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index 0ab7ac9..e281b66 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -59,8 +59,11 @@ our @EXPORT_OK = qw( sigwarn_silencer modver_gt_or_eq fail_on_internal_wantarray refcount hrefaddr is_exception is_plain_value is_literal_value + UNRESOLVABLE_CONDITION ); +use constant UNRESOLVABLE_CONDITION => \ '1 = 0'; + sub sigwarn_silencer ($) { my $pattern = shift;