File Coverage

File:blib/lib/MySQL/Util/Lite/ForeignKey.pm
Coverage:97.2%

linestmtbrancondsubcode
1package MySQL::Util::Lite::ForeignKey;
2
3our $VERSION = '0.01';
4
5
1
1
1
use Modern::Perl;
6
1
1
1
use Moose;
7
1
1
1
use namespace::autoclean;
8
1
1
1
use Method::Signatures;
9
1
1
1
use Data::Printer alias => 'pdump';
10
1
1
1
use MySQL::Util::Lite::ForeignKeyColumn;
11
12has name => (
13        is       => 'ro',
14        isa      => 'Str',
15        required => 1,
16);
17
18has schema_name => (
19        is       => 'ro',
20        isa      => 'Str',
21        required => 1,
22);
23
24has _util => (
25        is       => 'ro',
26        isa      => 'MySQL::Util',
27        required => 1,
28);
29
30
1
10
10
method get_columns {
31
32
10
        my $aref = $self->_util->get_constraint(
33                name  => $self->name
34        );
35
36
10
        my @cols;
37
38
10
        foreach my $col (@$aref) {
39
10
                push @cols, MySQL::Util::Lite::ForeignKeyColumn->new(
40                        name        => $col->{COLUMN_NAME},
41                        table_name  => $col->{TABLE_NAME},
42                        schema_name => $col->{CONSTRAINT_SCHEMA},
43                        parent_column_name => $col->{REFERENCED_COLUMN_NAME},
44                        parent_table_name  => $col->{REFERENCED_TABLE_NAME},
45                        parent_schema_name => $col->{REFERENCED_TABLE_SCHEMA},
46                );
47
48        }
49
50
10
        return @cols;
51}
52
531;