line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
18
|
|
|
18
|
|
792
|
use strict; |
|
18
|
|
|
|
|
27
|
|
|
18
|
|
|
|
|
1764
|
|
2
|
18
|
|
|
18
|
|
85
|
use warnings; |
|
18
|
|
|
|
|
26
|
|
|
18
|
|
|
|
|
707
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package UR::DataSource::RDBMS::TableColumn; |
5
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
66
|
use UR; |
|
18
|
|
|
|
|
22
|
|
|
18
|
|
|
|
|
91
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
UR::Object::Type->define( |
10
|
|
|
|
|
|
|
class_name => 'UR::DataSource::RDBMS::TableColumn', |
11
|
|
|
|
|
|
|
is => ['UR::DataSource::RDBMS::Entity'], |
12
|
|
|
|
|
|
|
dsmap => 'dd_table_column', |
13
|
|
|
|
|
|
|
er_role => '', |
14
|
|
|
|
|
|
|
id_properties => [qw/data_source table_name column_name/], |
15
|
|
|
|
|
|
|
properties => [ |
16
|
|
|
|
|
|
|
column_name => { type => 'varchar', len => undef, sql => 'column_name' }, |
17
|
|
|
|
|
|
|
data_source => { type => 'varchar', len => undef, sql => 'data_source' }, |
18
|
|
|
|
|
|
|
data_source_obj => { type => 'UR::DataSource', id_by => 'data_source'}, |
19
|
|
|
|
|
|
|
namespace => { calculate_from => [ 'data_source'], |
20
|
|
|
|
|
|
|
calculate => q( (split(/::/,$data_source))[0] ) }, |
21
|
|
|
|
|
|
|
owner => { type => 'varchar', len => undef, is_optional => 1, sql => 'owner' }, |
22
|
|
|
|
|
|
|
table_name => { type => 'varchar', len => undef, sql => 'table_name' }, |
23
|
|
|
|
|
|
|
data_length => { type => 'varchar', len => undef, is_optional => 1, sql => 'data_length' }, |
24
|
|
|
|
|
|
|
data_type => { type => 'varchar', len => undef, sql => 'data_type' }, |
25
|
|
|
|
|
|
|
last_object_revision => { type => 'timestamp', len => undef, sql => 'last_object_revision' }, |
26
|
|
|
|
|
|
|
nullable => { type => 'varchar', len => undef, sql => 'nullable' }, |
27
|
|
|
|
|
|
|
remarks => { type => 'varchar', len => undef, is_optional => 1, sql => 'remarks' }, |
28
|
|
|
|
|
|
|
], |
29
|
|
|
|
|
|
|
data_source => 'UR::DataSource::Meta', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Methods moved over from the old App::DB::TableColumn |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _fk_constraint_class { |
35
|
0
|
|
|
0
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if (ref($self) =~ /::Ghost$/) { |
38
|
0
|
|
|
|
|
|
return "UR::DataSource::RDBMS::FkConstraint::Ghost" |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
return "UR::DataSource::RDBMS::FkConstraint" |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_table { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $table_name = $self->table_name; |
49
|
0
|
|
|
|
|
|
my $data_source = $self->data_source; |
50
|
0
|
0
|
|
|
|
|
$data_source or Carp::confess("Can't determine data_source for table $table_name column ".$self->column_name ); |
51
|
0
|
|
0
|
|
|
|
my $table = |
52
|
|
|
|
|
|
|
UR::DataSource::RDBMS::Table->get(table_name => $table_name, data_source => $data_source) |
53
|
|
|
|
|
|
|
|| |
54
|
|
|
|
|
|
|
UR::DataSource::RDBMS::Table::Ghost->get(table_name => $table_name, data_source => $data_source); |
55
|
0
|
|
|
|
|
|
return $table; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub fk_constraint_names { |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
0
|
|
my @fks = shift->fk_constraints; |
62
|
0
|
|
|
|
|
|
return map { $_->fk_constraint_name } @fks; |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub fk_constraints { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $fk_class = $self->_fk_constraint_class(); |
70
|
0
|
|
|
|
|
|
my @fks = $fk_class->get(table_name => $self->table_name, |
71
|
|
|
|
|
|
|
data_source => $self->data_source); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return @fks; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub bitmap_index_names { |
78
|
0
|
|
|
0
|
0
|
|
Carp::confess("not implemented yet?!"); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# the update classes code uses this. If the data type of a column is a time-ish format, then |
83
|
|
|
|
|
|
|
# the data_length reported by the schema is the number of bytes used internally by the DB. |
84
|
|
|
|
|
|
|
# Since the UR-object will store the time in text format, it will always be longer than |
85
|
|
|
|
|
|
|
# that. To keep $obj->__errors__ from complaining, don't even bother storing the length of |
86
|
|
|
|
|
|
|
# time-ish data |
87
|
|
|
|
|
|
|
sub is_time_data { |
88
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $type = $self->data_type; |
91
|
0
|
0
|
|
|
|
|
if ($type =~ m/TIMESTAMP|DATE|INTERVAL/i) { |
92
|
0
|
|
|
|
|
|
return 1; |
93
|
|
|
|
|
|
|
} else { |
94
|
0
|
|
|
|
|
|
return; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
UR::DataSource::RDBMS::TableColumn - metadata about a data source's table's columns |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This class represents instances of columns in a data source's tables. They are |
109
|
|
|
|
|
|
|
maintained by 'ur update classes' and stored in the namespace's MetaDB. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|