| 1 | package Fey::SQL::Delete; | ||||||||||
| 2 | |||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 27 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 27 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 27 | our $VERSION = '0.44'; | |||||||||
| 8 | |||||||||||
| 9 | 27 | ▶ | use Fey::Types qw( ArrayRef CanQuote Table ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 27 | ▶ | use Scalar::Util qw( blessed ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 27 | ▶ | use Moose 2.1200; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 27 | ▶ | use MooseX::Params::Validate 0.21 qw( pos_validated_list ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 27 | ▶ | use MooseX::SemiAffordanceAccessor 0.03; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 27 | ▶ | use MooseX::StrictConstructor 0.13; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 27 | with 'Fey::Role::SQL::HasWhereClause', | |||||||||
| 18 | 'Fey::Role::SQL::HasOrderByClause', | ||||||||||
| 19 | 'Fey::Role::SQL::HasLimitClause'; | ||||||||||
| 20 | |||||||||||
| 21 | 27 | with 'Fey::Role::SQL::HasBindParams' => { -excludes => 'bind_params' }; | |||||||||
| 22 | |||||||||||
| 23 | has '_from' => ( | ||||||||||
| 24 | is => 'rw', | ||||||||||
| 25 | isa => ArrayRef, | ||||||||||
| 26 | 6 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 27 | init_arg => undef, | |||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 27 | with 'Fey::Role::SQL::Cloneable'; | |||||||||
| 31 | |||||||||||
| 32 | 6 | ▶ | sub delete { return $_[0] } | ||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 33 | |||||||||||
| 34 | 6 | ▶ | sub from { | ||||||||
|
Subroutine
from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | 6 | my $self = shift; | |||||||||
| 36 | |||||||||||
| 37 | 6 | ▶ | my $count = @_ ? @_ : 1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 6 | my (@tables) = pos_validated_list( | |||||||||
| 39 | \@_, | ||||||||||
| 40 | ( ( { isa => Table } ) x $count ), | ||||||||||
| 41 | MX_PARAMS_VALIDATE_NO_CACHE => 1, | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | 5 | $self->_set_from( \@tables ); | |||||||||
| 45 | |||||||||||
| 46 | 5 | return $self; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 3 | ▶ | sub sql { | ||||||||
|
Subroutine
sql: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 3 | my $self = shift; | |||||||||
| 51 | 3 | my ($dbh) = pos_validated_list( \@_, { isa => CanQuote } ); | |||||||||
| 52 | |||||||||||
| 53 | return ( | ||||||||||
| 54 | 3 | join ' ', | |||||||||
| 55 | $self->delete_clause($dbh), | ||||||||||
| 56 | $self->where_clause($dbh), | ||||||||||
| 57 | $self->order_by_clause($dbh), | ||||||||||
| 58 | $self->limit_clause($dbh), | ||||||||||
| 59 | ); | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 5 | ▶ | sub delete_clause { | ||||||||
|
Subroutine
delete_clause: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 63 | 5 | return 'DELETE FROM ' . $_[0]->_tables_subclause( $_[1] ); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 5 | ▶ | sub _tables_subclause { | ||||||||
|
Subroutine
_tables_subclause: called CC=1 SCAR=0.0
| |||||||||||
| 67 | return ( | ||||||||||
| 68 | join ', ', | ||||||||||
| 69 | 5 | map { $_[1]->quote_identifier( $_->name() ) } @{ $_[0]->_from() } | |||||||||
| 70 | ); | ||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 27 | __PACKAGE__->meta()->make_immutable(); | |||||||||
| 74 | |||||||||||
| 75 | 27 | 1; | |||||||||
| 76 | |||||||||||
| 77 | # ABSTRACT: Represents a DELETE query | ||||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||