| 1 | package DBIx::Class::Async::Exception::RelationshipAsColumn; | ||||||||||||
| 2 | |||||||||||||
| 3 | 102 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 102 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 102 | ▶ | use version; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 102 | our $VERSION = qv('v1.2.0'); | |||||||||||
| 8 | 102 | our $AUTHORITY = 'cpan:MANWAR'; | |||||||||||
| 9 | |||||||||||||
| 10 | 102 | ▶ | use parent 'DBIx::Class::Async::Exception'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | =head1 NAME | ||||||||||||
| 13 | |||||||||||||
| 14 | DBIx::Class::Async::Exception::RelationshipAsColumn - Exception for relationship | ||||||||||||
| 15 | name passed where a column was expected | ||||||||||||
| 16 | |||||||||||||
| 17 | =head1 VERSION | ||||||||||||
| 18 | |||||||||||||
| 19 | Version v1.2.0 | ||||||||||||
| 20 | |||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||
| 22 | |||||||||||||
| 23 | use DBIx::Class::Async::Exception::RelationshipAsColumn; | ||||||||||||
| 24 | |||||||||||||
| 25 | DBIx::Class::Async::Exception::RelationshipAsColumn->throw( | ||||||||||||
| 26 | message => "[DBIx::Class::Async] Relationship 'Details' passed where a column was expected", | ||||||||||||
| 27 | relationship => 'Details', | ||||||||||||
| 28 | relationship_type => 'multi', | ||||||||||||
| 29 | source_class => 'My::Schema::Result::Operation', | ||||||||||||
| 30 | operation => 'update_or_create', | ||||||||||||
| 31 | hint => "Omit 'Details' from the hashref if you have no related rows to insert.", | ||||||||||||
| 32 | original_error => $raw_dbic_error, | ||||||||||||
| 33 | ); | ||||||||||||
| 34 | |||||||||||||
| 35 | # Catch specifically | ||||||||||||
| 36 | use Try::Tiny; | ||||||||||||
| 37 | try { ... } catch { | ||||||||||||
| 38 | if ( ref $_ && $_->isa('DBIx::Class::Async::Exception::RelationshipAsColumn') ) { | ||||||||||||
| 39 | warn sprintf "Relationship '%s' (type: %s) was passed as a column.\n%s\n", | ||||||||||||
| 40 | $_->relationship, $_->relationship_type, $_->hint; | ||||||||||||
| 41 | } | ||||||||||||
| 42 | }; | ||||||||||||
| 43 | |||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||
| 45 | |||||||||||||
| 46 | Thrown when a C<has_many>, C<belongs_to>, or C<might_have> relationship name is | ||||||||||||
| 47 | used as a key in a create/update hashref with an C<undef> value, causing | ||||||||||||
| 48 | L<DBIx::Class> to die internally with "No such column". This corresponds to | ||||||||||||
| 49 | L<https://rt.cpan.org/Public/Bug/Display.html?id=127065|RT#127065>. | ||||||||||||
| 50 | |||||||||||||
| 51 | Inherits all methods from L<DBIx::Class::Async::Exception> and adds | ||||||||||||
| 52 | L</relationship> and L</relationship_type>. | ||||||||||||
| 53 | |||||||||||||
| 54 | =cut | ||||||||||||
| 55 | |||||||||||||
| 56 | 4 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 57 | 4 | my ($class, %args) = @_; | |||||||||||
| 58 | 4 | my $self = $class->SUPER::new(%args); | |||||||||||
| 59 | 4 | $self->{relationship} = $args{relationship}; | |||||||||||
| 60 | 4 | ▶ | $self->{relationship_type} = $args{relationship_type} // 'relationship'; | ||||||||||
|
Condition100%2/2
$args{"relationship_type"} // "relationship"
MC/DC100%1/1
$args{"relationship_type"} // "relationship"
$args{"relationship_type"}
Truth table100%2/2
A
A= $args{"relationship_type"}
| |||||||||||||
| 61 | 4 | return $self; | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | =head1 METHODS | ||||||||||||
| 65 | |||||||||||||
| 66 | Inherits C<throw>, C<rethrow>, C<message>, C<hint>, C<original_error>, | ||||||||||||
| 67 | C<operation>, C<source_class>, and C<stacktrace> from | ||||||||||||
| 68 | L<DBIx::Class::Async::Exception>. | ||||||||||||
| 69 | |||||||||||||
| 70 | =head2 relationship | ||||||||||||
| 71 | |||||||||||||
| 72 | my $name = $exception->relationship; | ||||||||||||
| 73 | |||||||||||||
| 74 | The name of the relationship that was incorrectly passed as a column key, | ||||||||||||
| 75 | e.g. C<'Details'>. | ||||||||||||
| 76 | |||||||||||||
| 77 | =cut | ||||||||||||
| 78 | |||||||||||||
| 79 | 3 | ▶ | sub relationship { $_[0]->{relationship} } | ||||||||||
|
Subroutine
relationship: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 80 | |||||||||||||
| 81 | =head2 relationship_type | ||||||||||||
| 82 | |||||||||||||
| 83 | my $type = $exception->relationship_type; | ||||||||||||
| 84 | |||||||||||||
| 85 | The relationship accessor type, e.g. C<'multi'> (has_many), C<'single'> | ||||||||||||
| 86 | (might_have / belongs_to), or C<'filter'>. Defaults to C<'relationship'> when | ||||||||||||
| 87 | the type cannot be determined. | ||||||||||||
| 88 | |||||||||||||
| 89 | =cut | ||||||||||||
| 90 | |||||||||||||
| 91 | 3 | ▶ | sub relationship_type { $_[0]->{relationship_type} } | ||||||||||
|
Subroutine
relationship_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 92 | |||||||||||||
| 93 | =head1 SEE ALSO | ||||||||||||
| 94 | |||||||||||||
| 95 | L<DBIx::Class::Async::Exception>, L<DBIx::Class::Async::Exception::Factory> | ||||||||||||
| 96 | |||||||||||||
| 97 | =head1 AUTHOR | ||||||||||||
| 98 | |||||||||||||
| 99 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||
| 100 | |||||||||||||
| 101 | =head1 REPOSITORY | ||||||||||||
| 102 | |||||||||||||
| 103 | L<https://github.com/manwar/DBIx-Class-Async> | ||||||||||||
| 104 | |||||||||||||
| 105 | =head1 BUGS | ||||||||||||
| 106 | |||||||||||||
| 107 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/DBIx-Class-Async/issues>. | ||||||||||||
| 108 | I will be notified and then you'll automatically be notified of progress on your | ||||||||||||
| 109 | bug as I make changes. | ||||||||||||
| 110 | |||||||||||||
| 111 | =head1 SUPPORT | ||||||||||||
| 112 | |||||||||||||
| 113 | You can find documentation for this module with the perldoc command. | ||||||||||||
| 114 | |||||||||||||
| 115 | perldoc DBIx::Class::Async::Exception::RelationshipAsColumn | ||||||||||||
| 116 | |||||||||||||
| 117 | You can also look for information at: | ||||||||||||
| 118 | |||||||||||||
| 119 | =over 4 | ||||||||||||
| 120 | |||||||||||||
| 121 | =item * BUG Report | ||||||||||||
| 122 | |||||||||||||
| 123 | L<https://github.com/manwar/DBIx-Class-Async/issues> | ||||||||||||
| 124 | |||||||||||||
| 125 | =item * CPAN Ratings | ||||||||||||
| 126 | |||||||||||||
| 127 | L<http://cpanratings.perl.org/d/DBIx-Class-Async> | ||||||||||||
| 128 | |||||||||||||
| 129 | =item * Search MetaCPAN | ||||||||||||
| 130 | |||||||||||||
| 131 | L<https://metacpan.org/dist/DBIx-Class-Async/> | ||||||||||||
| 132 | |||||||||||||
| 133 | =back | ||||||||||||
| 134 | |||||||||||||
| 135 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 136 | |||||||||||||
| 137 | Copyright (C) 2026 Mohammad Sajid Anwar. | ||||||||||||
| 138 | |||||||||||||
| 139 | This program is free software; you can redistribute it and / or modify it under | ||||||||||||
| 140 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||||||||||||
| 141 | license at: | ||||||||||||
| 142 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||
| 143 | Any use, modification, and distribution of the Standard or Modified Versions is | ||||||||||||
| 144 | governed by this Artistic License.By using, modifying or distributing the Package, | ||||||||||||
| 145 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||||||||||||
| 146 | not accept this license. | ||||||||||||
| 147 | If your Modified Version has been derived from a Modified Version made by someone | ||||||||||||
| 148 | other than you,you are nevertheless required to ensure that your Modified Version | ||||||||||||
| 149 | complies with the requirements of this license. | ||||||||||||
| 150 | This license does not grant you the right to use any trademark, service mark, | ||||||||||||
| 151 | tradename, or logo of the Copyright Holder. | ||||||||||||
| 152 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||||||||||||
| 153 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||||||||||||
| 154 | Package with respect to any patent claims licensable by the Copyright Holder that | ||||||||||||
| 155 | are necessarily infringed by the Package. If you institute patent litigation | ||||||||||||
| 156 | (including a cross-claim or counterclaim) against any party alleging that the | ||||||||||||
| 157 | Package constitutes direct or contributory patent infringement,then this Artistic | ||||||||||||
| 158 | License to you shall terminate on the date that such litigation is filed. | ||||||||||||
| 159 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||||||||||||
| 160 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||||||||||||
| 161 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||||||||||||
| 162 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||||||||||||
| 163 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||||||||||||
| 164 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||||||||||||
| 165 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||
| 166 | |||||||||||||
| 167 | =cut | ||||||||||||
| 168 | |||||||||||||
| 169 | 102 | 1; # End of DBIx::Class::Async::Exception::RelationshipAsColumn | |||||||||||