-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetColumns.pm
71 lines (53 loc) · 1.2 KB
/
GetColumns.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package MySQL::Util::Test::GetColumns;
use Modern::Perl;
use Data::Dumper;
use Test::More;
use MySQL::Util;
use Smart::Args;
use lib '.', './t';
use MySQL::Util::Test::Common qw(
get_mysql_util
load_db
);
sub test {
my $self = shift;
my $util = $self->{util};
my @cols = $util->get_columns( table => 'table_a' );
ok( @cols == 3 );
@cols = $util->get_columns( table => 'table_a', exclude_autoinc => 1 );
ok( @cols == 2 );
@cols = $util->get_columns( table => 'table_a', exclude_pk => 1 );
ok( @cols == 2 );
@cols = $util->get_columns(
table => 'table_a',
exclude_autoinc => 1,
exclude_pk => 1
);
ok( @cols == 2 );
}
sub should_fail {
my $self = shift;
my $util = $self->{util};
eval { $util->get_columns( table => 'table_a', uc => 1, lc => 1 ); };
ok($@);
}
sub run {
my $self = shift;
$self->test;
$self->should_fail;
}
sub new {
args
# required
my $class => 'Str',
# optional
my $util => { optional => 1, isa => 'MySQL::Util' },
my $load_db => { optional => 1, isa => 'Bool', default => 1 };
my $self = {};
if ($load_db) {
load_db();
}
$self->{util} = $util ? $util : get_mysql_util();
return bless $self, $class;
}
1;