| 1 | package DBomb::Meta::Key; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | DBomb::Meta::Key - An vector of columns. | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | =cut | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | our $VERSION = '$Revision: 1.13 $'; | |||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Tie::IxHash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use Carp::Assert; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | use Class::MethodMaker | ||||||||||
| 18 | 1 | ▶ | 'new_with_init' => 'new', | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 'get_set' => [qw(columns)], # IxHash{ column_name => column_info } | ||||||||||
| 20 | 'boolean' => [qw(is_pk)], | ||||||||||
| 21 | 1 | ; | |||||||||
| 22 | |||||||||||
| 23 | ## init( $cols_list, $opts) | ||||||||||
| 24 | sub init | ||||||||||
| 25 | 0 | ▶ | { | ||||||||
|
Subroutine
init: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 26 | 0 | my ($self, $cols_list, $opts) = @_; | |||||||||
| 27 | 0 | my %h; | |||||||||
| 28 | 0 | tie %h, 'Tie::IxHash'; | |||||||||
| 29 | 0 | $self->columns(\%h); | |||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | $cols_list = [$cols_list] if ref($cols_list) ne 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | for my $cinfo (@$cols_list){ | |||||||||
| 33 | 0 | $self->columns->{$cinfo->name} = $cinfo; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | ## Register with table info | ||||||||||
| 37 | 0 | push @{$self->table_info->keys}, $self; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | sub table_info | ||||||||||
| 41 | 0 | ▶ | { | ||||||||
|
Subroutine
table_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 42 | 0 | my $self = shift; | |||||||||
| 43 | 0 | assert(@_ == 0); | |||||||||
| 44 | 0 | tied(%{$self->columns})->Values(0)->table_info; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | sub columns_list | ||||||||||
| 48 | 0 | ▶ | { | ||||||||
|
Subroutine
columns_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | 0 | my $self = shift; | |||||||||
| 50 | 0 | assert(@_ == 0); | |||||||||
| 51 | 0 | [values %{$self->columns}] | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | sub column_names | ||||||||||
| 55 | 0 | ▶ | { | ||||||||
|
Subroutine
column_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | 0 | assert(@_ == 0); | |||||||||
| 58 | 0 | [keys %{$self->columns}] | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub column_count | ||||||||||
| 62 | 0 | ▶ | { | ||||||||
|
Subroutine
column_count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | 0 | my $self = shift; | |||||||||
| 64 | 0 | assert(@_ == 0); | |||||||||
| 65 | 0 | tied(%{$self->columns})->Length; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | sub resolve | ||||||||||
| 69 | 0 | ▶ | { | ||||||||
|
Subroutine
resolve: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 70 | ## No action. | ||||||||||
| 71 | 0 | return 1; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | ## returns a where clause optionally with bind values | ||||||||||
| 75 | ## mk_where(@bind_values) | ||||||||||
| 76 | sub mk_where | ||||||||||
| 77 | 0 | ▶ | { | ||||||||
|
Subroutine
mk_where: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 78 | 0 | my $self = shift; | |||||||||
| 79 | 0 | my $where = new DBomb::Query::Expr(); | |||||||||
| 80 | |||||||||||
| 81 | 0 | for (values %{$self->columns}){ | |||||||||
| 82 | 0 | $where->and(+{$_->fq_name => '?'}); | |||||||||
| 83 | } | ||||||||||
| 84 | 0 | ▶ | push @{$where->bind_values}, @_ if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | |||||||||||
| 86 | 0 | return $where; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | |||||||||||
| 90 | 1 | 1; | |||||||||
| 91 | __END__ | ||||||||||