@@ -1832,7 +1832,7 @@ sub reverse_relationship_info {
1832
1832
# Some custom rels may not resolve without a $schema
1833
1833
#
1834
1834
my $our_resolved_relcond = dbic_internal_try {
1835
- $self -> _resolve_relationship_condition (
1835
+ $self -> resolve_relationship_condition (
1836
1836
rel_name => $rel ,
1837
1837
1838
1838
# an API where these are optional would be too cumbersome,
@@ -1898,7 +1898,7 @@ sub reverse_relationship_info {
1898
1898
and
1899
1899
1900
1900
my $their_resolved_relcond = dbic_internal_try {
1901
- $other_rsrc -> _resolve_relationship_condition (
1901
+ $other_rsrc -> resolve_relationship_condition (
1902
1902
rel_name => $other_rel ,
1903
1903
1904
1904
# an API where these are optional would be too cumbersome,
@@ -2096,7 +2096,7 @@ sub _resolve_join {
2096
2096
-alias => $as ,
2097
2097
-relation_chain_depth => ( $seen -> {-relation_chain_depth} || 0 ) + 1,
2098
2098
},
2099
- $self -> _resolve_relationship_condition (
2099
+ $self -> resolve_relationship_condition (
2100
2100
rel_name => $join ,
2101
2101
self_alias => $alias ,
2102
2102
foreign_alias => $as ,
@@ -2169,18 +2169,29 @@ sub _compare_relationship_keys :DBIC_method_is_indirect_sugar {
2169
2169
bag_eq( $_ [1], $_ [2] );
2170
2170
}
2171
2171
2172
- sub resolve_condition {
2173
- carp ' resolve_condition is a private method, stop calling it' ;
2172
+ sub _resolve_relationship_condition :DBIC_method_is_indirect_sugar {
2173
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
2174
+
2175
+ # carp() - has been on CPAN for less than 2 years
2176
+ carp ' _resolve_relationship_condition() is deprecated - see resolve_relationship_condition() instead' ;
2177
+
2178
+ shift -> resolve_relationship_condition(@_ );
2179
+ }
2180
+
2181
+ sub resolve_condition :DBIC_method_is_indirect_sugar {
2182
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
2183
+
2184
+ # carp() - has been discouraged forever
2185
+ carp ' resolve_condition() is deprecated - see resolve_relationship_condition() instead' ;
2186
+
2174
2187
shift -> _resolve_condition (@_ );
2175
2188
}
2176
2189
2177
- sub _resolve_condition {
2178
- # carp_unique sprintf
2179
- # '_resolve_condition is a private method, and moreover is about to go '
2180
- # . 'away. Please contact the development team at %s if you believe you '
2181
- # . 'have a genuine use for this method, in order to discuss alternatives.',
2182
- # DBIx::Class::_ENV_::HELP_URL,
2183
- # ;
2190
+ sub _resolve_condition :DBIC_method_is_indirect_sugar {
2191
+ DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
2192
+
2193
+ # carp_unique() - the interface replacing it only became reality in Sep 2016
2194
+ carp_unique ' _resolve_condition() is deprecated - see resolve_relationship_condition() instead' ;
2184
2195
2185
2196
# ######################
2186
2197
# ## API Design? What's that...? (a backwards compatible shim, kill me now)
@@ -2232,21 +2243,21 @@ sub _resolve_condition {
2232
2243
};
2233
2244
2234
2245
# Allowing passing relconds different than the relationshup itself is cute,
2235
- # but likely dangerous. Remove that from the (still unofficial) API of
2236
- # _resolve_relationship_condition, and instead make it "hard on purpose"
2246
+ # but likely dangerous. Remove that from the API of resolve_relationship_condition,
2247
+ # and instead make it "hard on purpose"
2237
2248
local $self -> relationship_info( $args -> {rel_name } )-> {cond } = $cond if defined $cond ;
2238
2249
2239
2250
# ######################
2240
2251
2241
2252
# now it's fucking easy isn't it?!
2242
- my $rc = $self -> _resolve_relationship_condition ( $args );
2253
+ my $rc = $self -> resolve_relationship_condition ( $args );
2243
2254
2244
2255
my @res = (
2245
2256
( $rc -> {join_free_condition } || $rc -> {condition } ),
2246
2257
! $rc -> {join_free_condition },
2247
2258
);
2248
2259
2249
- # _resolve_relationship_condition always returns qualified cols even in the
2260
+ # resolve_relationship_condition always returns qualified cols even in the
2250
2261
# case of join_free_condition, but nothing downstream expects this
2251
2262
if ($rc -> {join_free_condition } and ref $res [0] eq ' HASH' ) {
2252
2263
$res [0] = { map
@@ -2268,34 +2279,73 @@ our $UNRESOLVABLE_CONDITION = UNRESOLVABLE_CONDITION;
2268
2279
# we are moving to a constant
2269
2280
Internals::SvREADONLY($UNRESOLVABLE_CONDITION => 1);
2270
2281
2271
- # Resolves the passed condition to a concrete query fragment and extra
2272
- # metadata
2273
- #
2274
- # # self-explanatory API, modeled on the custom cond coderef:
2275
- # rel_name => (scalar)
2276
- # foreign_alias => (scalar)
2277
- # foreign_values => (either not supplied or a hashref )
2278
- # self_alias => (scalar)
2279
- # self_result_object => (either not supplied or a result object)
2280
- # require_join_free_condition => (boolean, throws on failure to construct a JF-cond)
2281
- # require_join_free_values => (boolean, throws on failure to return an equality-only JF-cond, implies require_join_free_condition)
2282
- #
2283
- # # returns a hash
2284
- # condition => (a valid *likely fully qualified* sqla cond structure)
2285
- # identity_map => (a hashref of foreign-to-self *unqualified* column equality names)
2286
- # identity_map_matches_condition => (boolean, indicates whether the entire condition is expressed in the identity-map)
2287
- # join_free_condition => (a valid *fully qualified* sqla cond structure, maybe unset)
2288
- # join_free_values => (IFF the returned join_free_condition contains only exact values (no expressions)
2289
- # this would be a hashref of identical join_free_condition, except with all column
2290
- # names *unqualified* )
2291
- #
2292
- sub _resolve_relationship_condition {
2282
+ =head2 resolve_relationship_condition
2283
+
2284
+ NOTE: You generally B<SHOULD NOT > need to use this functionality... until you
2285
+ do. The API description is terse on purpose. If the text below doesn't make
2286
+ sense right away (based on the context which prompted you to look here) it is
2287
+ almost certain you are reaching for the wrong tool. Please consider asking for
2288
+ advice in any of the support channels before proceeding.
2289
+
2290
+ =over 4
2291
+
2292
+ =item Arguments: C<\%args > as shown below (C<B<* > > denotes mandatory args):
2293
+
2294
+ * rel_name => $string
2295
+
2296
+ * foreign_alias => $string
2297
+
2298
+ * self_alias => $string
2299
+
2300
+ foreign_values => \%column_value_pairs
2301
+
2302
+ self_result_object => $ResultObject
2303
+
2304
+ require_join_free_condition => $bool ( results in exception on failure to construct a JF-cond )
2305
+
2306
+ require_join_free_values => $bool ( results in exception on failure to return an equality-only JF-cond )
2307
+
2308
+ =item Return Value: C<\%resolution_result > as shown below (C<B<* > > denotes always-resent parts of the result):
2309
+
2310
+ * condition => $sqla_condition ( always present, valid, *likely* fully qualified, SQL::Abstract-compatible structure )
2311
+
2312
+ identity_map => \%foreign_to_self_equailty_map ( list of declared-equal foreign/self *unqualified* column names )
2313
+
2314
+ identity_map_matches_condition => $bool ( indicates whether the entire condition is expressed within the identity_map )
2315
+
2316
+ join_free_condition => \%sqla_condition_fully_resolvable_via_foreign_table
2317
+ ( always a hash, all keys guaranteed to be valid *fully qualified* columns )
2318
+
2319
+ join_free_values => \%unqalified_version_of_join_free_condition
2320
+ ( IFF the returned join_free_condition contains only exact values (no expressions), this would be
2321
+ a hashref identical to join_free_condition, except with all column names *unqualified* )
2322
+
2323
+ =back
2324
+
2325
+ This is the low-level method used to convert a declared relationship into
2326
+ various parameters consumed by higher level functions. It is provided as a
2327
+ stable official API, as the logic it encapsulates grew incredibly complex with
2328
+ time. While calling this method directly B<is generally discouraged > , you
2329
+ absolutely B<should be using it > in codepaths containing the moral equivalent
2330
+ of:
2331
+
2332
+ ...
2333
+ if( ref $some_rsrc->relationship_info($somerel)->{cond} eq 'HASH' ) {
2334
+ ...
2335
+ }
2336
+ ...
2337
+
2338
+ =cut
2339
+
2340
+ # TODO - expand the documentation above, too terse
2341
+
2342
+ sub resolve_relationship_condition {
2293
2343
my $self = shift ;
2294
2344
2295
2345
my $args = { ref $_ [0] eq ' HASH' ? %{ $_ [0] } : @_ };
2296
2346
2297
2347
for ( qw( rel_name self_alias foreign_alias ) ) {
2298
- $self -> throw_exception(" Mandatory argument '$_ ' to _resolve_relationship_condition () is not a plain string" )
2348
+ $self -> throw_exception(" Mandatory argument '$_ ' to resolve_relationship_condition () is not a plain string" )
2299
2349
if !defined $args -> {$_ } or length ref $args -> {$_ };
2300
2350
}
2301
2351
@@ -2560,7 +2610,7 @@ sub _resolve_relationship_condition {
2560
2610
else {
2561
2611
my @subconds = map {
2562
2612
local $rel_info -> {cond } = $_ ;
2563
- $self -> _resolve_relationship_condition ( $args );
2613
+ $self -> resolve_relationship_condition ( $args );
2564
2614
} @{ $rel_info -> {cond } };
2565
2615
2566
2616
if ( @{ $rel_info -> {cond } } == 1 ) {
0 commit comments