|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package MySQL::Workbench::DBIC;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
4164858
 | 
 use warnings;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
443
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1273
 | 
    | 
| 
4
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
222
 | 
 use strict;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
95
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
792
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
190
 | 
 use Carp;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
86
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2117
 | 
    | 
| 
7
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
24869
 | 
 use Data::Dumper;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
268721
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2630
 | 
    | 
| 
8
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
326
 | 
 use File::Path qw(make_path);  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
80
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2612
 | 
    | 
| 
9
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
297
 | 
 use File::Spec;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
91
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
770
 | 
    | 
| 
10
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
24890
 | 
 use JSON;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
459548
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
221
 | 
    | 
| 
11
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
5875
 | 
 use List::Util qw(first);  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
90
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2424
 | 
    | 
| 
12
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
21384
 | 
 use Moo;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
431142
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
227
 | 
    | 
| 
13
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
 
 | 
76016
 | 
 use MySQL::Workbench::Parser;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7203951
 | 
    | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
180984
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: create DBIC scheme for MySQL workbench .mwb files  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '1.19';  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has output_path              => ( is => 'ro', required => 1, default => sub { '.' } );  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has file                     => ( is => 'ro', required => 1 );  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has uppercase                => ( is => 'ro' );  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has inherit_from_core        => ( is => 'ro' );  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has namespace                => ( is => 'ro', isa => sub{ _check_namespace( @_, 1) }, required => 1, default => sub { '' } );  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has result_namespace         => ( is => 'ro', isa => \&_check_namespace, required => 1, default => sub { '' } );  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has resultset_namespace      => ( is => 'ro', isa => \&_check_namespace, required => 1, default => sub { '' } );  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has load_result_namespace    => ( is => 'ro', isa => \&_check_namespace_array, default => sub { '' } );  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has load_resultset_namespace => ( is => 'ro', isa => \&_check_namespace_array, default => sub { '' } );  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has schema_name              => ( is => 'rwp', isa => sub { defined $_[0] && $_[0] =~ m{ \A [A-Za-z0-9_]+ \z }xms } );  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has parser                   => ( is => 'rwp' );  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has version_add              => ( is => 'ro', required => 1, default => sub { 0.01 } );  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has column_details           => ( is => 'ro', required => 1, default => sub { 0 } );  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has use_fake_dbic            => ( is => 'ro', required => 1, default => sub { 0 } );  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has skip_indexes             => ( is => 'ro', required => 1, default => sub { 0 } );  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has belongs_to_prefix        => ( is => 'ro', required => 1, default => sub { '' } );  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has has_many_prefix          => ( is => 'ro', required => 1, default => sub { '' } );  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has has_one_prefix           => ( is => 'ro', required => 1, default => sub { '' } );  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has many_to_many_prefix      => ( is => 'ro', required => 1, default => sub { '' } );  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has utf8                     => ( is => 'ro', required => 1, default => sub { 0 } );  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has schema_base_class        => ( is => 'ro', required => 1, default => sub { 'DBIx::Class::Schema' } );  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has remove_table_prefix      => ( is => 'ro' );  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has version => ( is => 'rwp' );  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has classes => ( is => 'rwp', isa => sub { ref $_[0] && ref $_[0] eq 'ARRAY' }, default => sub { [] } );  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _check_namespace {  | 
| 
46
 | 
218
 | 
 
 | 
 
 | 
  
218
  
 | 
 
 | 
5554
 | 
     my ($namespace, $allow_empty_string) = @_;  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
218
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
575
 | 
     return if !defined $namespace;  | 
| 
49
 | 
216
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
471
 | 
     return if ref $namespace;  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
51
 | 
213
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
993
 | 
     return 1 if $namespace eq '' && $allow_empty_string;  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
200
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3282
 | 
     return $namespace =~ m{ \A [A-Z]\w*(::\w+)* \z }xms;  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _check_namespace_array {  | 
| 
57
 | 
87
 | 
 
 | 
 
 | 
  
87
  
 | 
 
 | 
5170
 | 
     my ($namespaces) = @_;  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
59
 | 
87
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
284
 | 
     if ( !ref $namespaces ) {  | 
| 
60
 | 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
209
 | 
         return _check_namespace( $namespaces );  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
63
 | 
13
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
36
 | 
     return if 'ARRAY' ne ref $namespaces;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
     for my $namespace ( @{ $namespaces } ) {  | 
| 
 
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
    | 
| 
66
 | 
20
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
57
 | 
         return if !_check_namespace( $namespace );  | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
69
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
85
 | 
     return 1;  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 around new => sub {  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my ($next, $class, %args) = @_;  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $args{use_fake_dbic} || !eval{ require DBIx::Class } ) {  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         require MySQL::Workbench::DBIC::FakeDBIC;  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $self = $class->$next( %args );  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $parser = MySQL::Workbench::Parser->new( file => $self->file );  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $self->_set_parser( $parser );  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self;  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 };  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub create_schema{  | 
| 
88
 | 
30
 | 
 
 | 
 
 | 
  
30
  
 | 
  
1
  
 | 
21479
 | 
     my $self = shift;  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
90
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
137
 | 
     my $parser = $self->parser;  | 
| 
91
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
66
 | 
     my @tables = @{ $parser->tables };  | 
| 
 
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
802
 | 
    | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
93
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
897420
 | 
     my @classes;  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my %relations;  | 
| 
95
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
109
 | 
     for my $table ( @tables ){  | 
| 
96
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
222
 | 
         my $name = $table->name;  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
98
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
200
 | 
         push @classes, $name;  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
100
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
230
 | 
         my $rels = $table->foreign_keys;  | 
| 
101
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
260
 | 
         for my $to_table ( keys %$rels ){  | 
| 
102
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
223
 | 
             $relations{$to_table}->{to}->{$name}   = $rels->{$to_table};  | 
| 
103
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
193
 | 
             $relations{$name}->{from}->{$to_table} = $rels->{$to_table};  | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
107
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
700
 | 
     $self->_set_classes( \@classes );  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
109
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
384
 | 
     my @scheme = $self->_main_template;  | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
111
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
     my @files;  | 
| 
112
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
84
 | 
     for my $table ( @tables ){  | 
| 
113
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
264
 | 
         my $custom_code = $self->_custom_code_table( $table );  | 
| 
114
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
619
 | 
         push @files, $self->_class_template( $table, $relations{$table->name}, $custom_code );  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
117
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
93
 | 
     push @files, @scheme;  | 
| 
118
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
119
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
131
 | 
     $self->_write_files( @files );  | 
| 
120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _custom_code_table {  | 
| 
123
 | 
85
 | 
 
 | 
 
 | 
  
85
  
 | 
 
 | 
218
 | 
     my ($self, $table) = @_;  | 
| 
124
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
125
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
     my $name = $table->name;  | 
| 
126
 | 
85
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
317
 | 
     if ( $self->uppercase ) {  | 
| 
127
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
128
 | 
         $name = join '', map{ ucfirst } split /[_-]/, $table->name;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
141
 | 
    | 
| 
128
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
129
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
130
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
152
 | 
     my @base_path;  | 
| 
131
 | 
85
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
356
 | 
     push @base_path, $self->output_path if $self->output_path;  | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
133
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1576
 | 
     my $path = File::Spec->catfile(  | 
| 
134
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         @base_path,  | 
| 
135
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         (split /::/, $self->namespace),  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $self->schema_name,  | 
| 
137
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $self->result_namespace,  | 
| 
138
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         'Result',  | 
| 
139
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $name . '.pm'  | 
| 
140
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
141
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
142
 | 
85
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1756
 | 
     return '' if !-f $path;  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
144
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
127
 | 
     return $self->_custom_code( $path );  | 
| 
145
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
146
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
147
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _custom_code {  | 
| 
148
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
109
 | 
     my ($self, $path) = @_;  | 
| 
149
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
150
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
106
 | 
     my $content = do { local (@ARGV, $/) = $path; <> };  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
205
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2456
 | 
    | 
| 
151
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
152
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
457
 | 
     my ($code) = $content =~ m{  | 
| 
153
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ^[#] \s+ --- \s*  | 
| 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ^[#] \s+ Put \s+ your \s+ own \s+ code \s+ below \s+ this \s+ comment \s*  | 
| 
155
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ^[#] \s+ --- \s*  | 
| 
156
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         (.*?) \s+  | 
| 
157
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ^[#] \s+ --- \s*  | 
| 
158
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }xms;  | 
| 
159
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
160
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
130
 | 
     return $code;  | 
| 
161
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
162
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
163
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _write_files{  | 
| 
164
 | 
32
 | 
 
 | 
 
 | 
  
32
  
 | 
 
 | 
1561
 | 
     my ($self, %files) = @_;  | 
| 
165
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
166
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
215
 | 
     for my $package ( keys %files ){  | 
| 
167
 | 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
331
 | 
         my @path;  | 
| 
168
 | 
117
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
595
 | 
         push @path, $self->output_path if $self->output_path;  | 
| 
169
 | 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
736
 | 
         push @path, split /::/, $package;  | 
| 
170
 | 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
297
 | 
         my $file = pop @path;  | 
| 
171
 | 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1301
 | 
         my $dir  = File::Spec->catdir( @path );  | 
| 
172
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
173
 | 
117
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
2406
 | 
         if( !-e $dir ){  | 
| 
174
 | 
32
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
15642
 | 
             make_path( $dir ) or croak "Cannot create directory $dir";  | 
| 
175
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
176
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
177
 | 
116
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
9831
 | 
         if( open my $fh, '>', $dir . '/' . $file . '.pm' ){  | 
| 
178
 | 
115
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
708
 | 
             if ( $self->utf8 ) {  | 
| 
179
 | 
4
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
70
 | 
                 binmode $fh, ':encoding(utf-8)';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    | 
| 
180
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
181
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
182
 | 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2929
 | 
             print $fh $files{$package};  | 
| 
183
 | 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5699
 | 
             close $fh;  | 
| 
184
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
185
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         else{  | 
| 
186
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
103
 | 
             croak "Couldn't create $file.pm: $!";  | 
| 
187
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
188
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
189
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
190
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
191
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _has_many_template{  | 
| 
192
 | 
54
 | 
 
 | 
 
 | 
  
54
  
 | 
 
 | 
1018
 | 
     my ($self, $to, $rels) = @_;  | 
| 
193
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
194
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
99
 | 
     my $to_class = $to;  | 
| 
195
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
90
 | 
     my $name     = $to;  | 
| 
196
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
197
 | 
54
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
200
 | 
     if ( defined $self->remove_table_prefix ) {  | 
| 
198
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         my $prefix = $self->remove_table_prefix;  | 
| 
199
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         $to_class  =~ s{\A\Q$prefix\E}{};  | 
| 
200
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         $name      =~ s{\A\Q$prefix\E}{};  | 
| 
201
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
202
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
203
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
165
 | 
     if ( $self->uppercase ) {  | 
| 
204
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
90
 | 
         $to_class = join '', map{ ucfirst $_ }split /[_-]/, $to;  | 
| 
 
 | 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126
 | 
    | 
| 
205
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
206
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
207
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
496
 | 
     my $package = join '::', (  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
208
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( $self->namespace ? $self->namespace : () ),  | 
| 
209
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $self->schema_name,  | 
| 
210
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( length $self->result_namespace ? $self->result_namespace : () ),  | 
| 
211
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        'Result',  | 
| 
212
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $to_class,  | 
| 
213
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
214
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
215
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
105
 | 
     my %has_many_rels;  | 
| 
216
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
101
 | 
     my $counter = 1;  | 
| 
217
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
218
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
98
 | 
     my $string = '';  | 
| 
219
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
92
 | 
     for my $field ( @{ $rels || [] } ) {  | 
| 
 
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
252
 | 
    | 
| 
220
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
154
 | 
         my $me_field      = $field->{foreign};  | 
| 
221
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
107
 | 
         my $foreign_field = $field->{me};  | 
| 
222
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
223
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
180
 | 
         my $temp_field = $self->has_many_prefix . $name;  | 
| 
224
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
177
 | 
         while ( $has_many_rels{$temp_field} ) {  | 
| 
225
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
             $temp_field = $self->has_many_prefix . $name . $counter++;  | 
| 
226
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
227
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
228
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
146
 | 
         $has_many_rels{$temp_field}++;  | 
| 
229
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
230
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
357
 | 
         $string .= qq~  | 
| 
231
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->has_many($temp_field => '$package',  | 
| 
232
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
              { 'foreign.$foreign_field' => 'self.$me_field' });  | 
| 
233
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ~;  | 
| 
234
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
235
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
236
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
235
 | 
     return $string;  | 
| 
237
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
238
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
239
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _belongs_to_template{  | 
| 
240
 | 
54
 | 
 
 | 
 
 | 
  
54
  
 | 
 
 | 
1059
 | 
     my ($self, $from, $rels) = @_;  | 
| 
241
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
242
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
110
 | 
     my $from_class = $from;  | 
| 
243
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
93
 | 
     my $name = $from;  | 
| 
244
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
245
 | 
54
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
209
 | 
     if ( defined $self->remove_table_prefix ) {  | 
| 
246
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         my $prefix  = $self->remove_table_prefix;  | 
| 
247
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         $from_class =~ s{\A\Q$prefix\E}{};  | 
| 
248
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         $name       =~ s{\A\Q$prefix\E}{};  | 
| 
249
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
250
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
251
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
181
 | 
     if ( $self->uppercase ) {  | 
| 
252
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
79
 | 
         $from_class = join '', map{ ucfirst $_ }split /[_-]/, $from;  | 
| 
 
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
70
 | 
    | 
| 
253
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
254
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
255
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
416
 | 
     my $package = join '::', (  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
256
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( $self->namespace ? $self->namespace : () ),  | 
| 
257
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $self->schema_name,  | 
| 
258
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( length $self->result_namespace ? $self->result_namespace : () ),  | 
| 
259
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        'Result',  | 
| 
260
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $from_class,  | 
| 
261
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
262
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
263
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
99
 | 
     my %belongs_to_rels;  | 
| 
264
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
104
 | 
     my $counter = 1;  | 
| 
265
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
266
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
92
 | 
     my $string = '';  | 
| 
267
 | 
54
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
89
 | 
     for my $field ( @{ $rels || [] } ) {  | 
| 
 
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
194
 | 
    | 
| 
268
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
142
 | 
         my $me_field      = $field->{me};  | 
| 
269
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
110
 | 
         my $foreign_field = $field->{foreign};  | 
| 
270
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
271
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
185
 | 
         my $temp_field = $self->belongs_to_prefix . $name;  | 
| 
272
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
212
 | 
         while ( $belongs_to_rels{$temp_field} ) {  | 
| 
273
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
             $temp_field = $self->belongs_to_prefix . $name . $counter++;  | 
| 
274
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
275
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
276
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
209
 | 
         $belongs_to_rels{$temp_field}++;  | 
| 
277
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
278
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
351
 | 
         $string .= qq~  | 
| 
279
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->belongs_to($temp_field => '$package',  | 
| 
280
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
              { 'foreign.$foreign_field' => 'self.$me_field' });  | 
| 
281
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ~;  | 
| 
282
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
283
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
284
 | 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
222
 | 
     return $string;  | 
| 
285
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
286
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
287
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _class_template{  | 
| 
288
 | 
89
 | 
 
 | 
 
 | 
  
89
  
 | 
 
 | 
5768
 | 
     my ($self, $table, $relations, $custom_code) = @_;  | 
| 
289
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
290
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
248
 | 
     my $name    = $table->name;  | 
| 
291
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
214
 | 
     my $class   = $name;  | 
| 
292
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
293
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
340
 | 
     if ( defined $self->remove_table_prefix ) {  | 
| 
294
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
         my $prefix = $self->remove_table_prefix;  | 
| 
295
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
         $class =~ s{\A\Q$prefix\E}{};  | 
| 
296
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
297
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
298
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
296
 | 
     if ( $self->uppercase ) {  | 
| 
299
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
130
 | 
         $class = join '', map{ ucfirst $_ }split /[_-]/, $name;  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
132
 | 
    | 
| 
300
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
301
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
302
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
708
 | 
     my $package = join '::', (  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
303
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( $self->namespace ? $self->namespace : () ),  | 
| 
304
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $self->schema_name,  | 
| 
305
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        ( length $self->result_namespace ? $self->result_namespace : () ),  | 
| 
306
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        'Result',  | 
| 
307
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
        $class,  | 
| 
308
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
309
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
310
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
224
 | 
     my ($has_many, $belongs_to) = ('','');  | 
| 
311
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
312
 | 
89
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
460
 | 
     my $comment = $table->comment // '{}';  | 
| 
313
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
292
 | 
     utf8::upgrade( $comment );  | 
| 
314
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
315
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
139
 | 
     my $data;  | 
| 
316
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
159
 | 
     my $table_comment_perl = '';  | 
| 
317
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
198
 | 
     eval {  | 
| 
318
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1161
 | 
         $data = JSON->new->decode( $comment );  | 
| 
319
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     };  | 
| 
320
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
321
 | 
89
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
978
 | 
     if ( !ref $data || 'HASH' ne ref $data ) {  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
322
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
33
 | 
         $data               = {};  | 
| 
323
 | 
7
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
24
 | 
         $table_comment_perl = $comment if $comment;  | 
| 
324
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
325
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     elsif ( $data->{comment} ) {  | 
| 
326
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
         $table_comment_perl = $data->{comment};  | 
| 
327
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
328
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
329
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
253
 | 
     if ( $table_comment_perl ) {  | 
| 
330
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
         $table_comment_perl = sprintf "\n\n=head1 DESCRIPTION\n\n%s\n\n=cut", $table_comment_perl;  | 
| 
331
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
332
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
333
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
434
 | 
     my @core_components = $self->inherit_from_core ? () : qw(PK::Auto Core);  | 
| 
334
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
169
 | 
     my $components      = join( ' ', @core_components, @{ $data->{components} || [] } );  | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
528
 | 
    | 
| 
335
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
330
 | 
     my $load_components = $components ? "__PACKAGE__->load_components( qw/$components/ );" : '';  | 
| 
336
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
337
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
164
 | 
     my %foreign_keys;  | 
| 
338
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
339
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
150
 | 
     for my $to_table ( sort keys %{ $relations->{to} } ){  | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
436
 | 
    | 
| 
340
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
213
 | 
         $has_many .= $self->_has_many_template( $to_table, $relations->{to}->{$to_table} );  | 
| 
341
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
342
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
343
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
196
 | 
     for my $from_table ( sort keys %{ $relations->{from} } ){  | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
415
 | 
    | 
| 
344
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
257
 | 
         $belongs_to .= $self->_belongs_to_template( $from_table, $relations->{from}->{$from_table} );  | 
| 
345
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
346
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
117
 | 
         my @foreign_key_names = map{ $_->{me} }@{ $relations->{from}->{$from_table} };  | 
| 
 
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
172
 | 
    | 
| 
 
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
154
 | 
    | 
| 
347
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
210
 | 
         @foreign_keys{ @foreign_key_names } = (1) x @foreign_key_names;  | 
| 
348
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
349
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
350
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
182
 | 
     my @columns = map{ $_->name }@{ $table->columns };  | 
| 
 
 | 
180
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1263
 | 
    | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2189
 | 
    | 
| 
351
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
269
 | 
     my $column_string = '';  | 
| 
352
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
353
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
402
 | 
     if ( !$self->column_details ) {  | 
| 
354
 | 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
123
 | 
         $column_string = "qw/\n" . join "\n", map{ "    " . $_ }@columns, "    /";  | 
| 
 
 | 
155
 | 
 
 | 
 
 | 
 
 | 
 
 | 
433
 | 
    | 
| 
355
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
356
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     else {  | 
| 
357
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
78
 | 
         my @columns = @{ $table->columns };  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
672
 | 
    | 
| 
358
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
359
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
327
 | 
         for my $column ( @columns ) {  | 
| 
360
 | 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
             $column_string .= $self->_column_details( $table, $column, \%foreign_keys, $data );  | 
| 
361
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
362
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
363
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
364
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
212
 | 
     my @indexes      = @{ $table->indexes };  | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1738
 | 
    | 
| 
365
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
958
 | 
     my $indexes_hook = $self->_indexes_template( @indexes );  | 
| 
366
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
367
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
185
 | 
     my $primary_key   = join " ", @{ $table->primary_key };  | 
| 
 
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
389
 | 
    | 
| 
368
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
295
 | 
     my $version       = $self->version;  | 
| 
369
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
350
 | 
     my $inherit_from  = $self->inherit_from_core ? '::Core' : '';  | 
| 
370
 | 
89
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
297
 | 
     my $use_utf8      = $self->utf8 ? "\nuse utf8;" : '';  | 
| 
371
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
372
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1576
 | 
     my $template = qq~package $package;  | 
| 
373
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
374
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Result class for $name$table_comment_perl  | 
| 
375
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
376
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use strict;  | 
| 
377
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use warnings;$use_utf8  | 
| 
378
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use base qw(DBIx::Class$inherit_from);  | 
| 
379
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
380
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our \$VERSION = $version;  | 
| 
381
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
382
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $load_components  | 
| 
383
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->table( '$name' );  | 
| 
384
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->add_columns(  | 
| 
385
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $column_string  | 
| 
386
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
387
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->set_primary_key( qw/ $primary_key / );  | 
| 
388
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
389
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $has_many  | 
| 
390
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $belongs_to  | 
| 
391
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
392
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $indexes_hook  | 
| 
393
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
394
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
395
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Put your own code below this comment  | 
| 
396
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
397
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $custom_code  | 
| 
398
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
399
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
400
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;~;  | 
| 
401
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
402
 | 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
694
 | 
     return $package, $template;  | 
| 
403
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
404
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
405
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _column_details {  | 
| 
406
 | 
88
 | 
 
 | 
 
 | 
  
88
  
 | 
 
 | 
11214
 | 
     my ($self, $table, $column, $foreign_keys, $data) = @_;  | 
| 
407
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
408
 | 
88
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
295
 | 
     my $default_value = $column->default_value // '';  | 
| 
409
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
185
 | 
     $default_value =~ s/'/\\'/g;  | 
| 
410
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
411
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
204
 | 
     my $size = $column->length;  | 
| 
412
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
413
 | 
88
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
561
 | 
     if ( $column->datatype =~ /char/i && $column->length <= 0 ) {  | 
| 
414
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
         $size = 255;  | 
| 
415
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
416
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
417
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
141
 | 
     my @options;  | 
| 
418
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
419
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
174
 | 
     my $name        = $column->name;  | 
| 
420
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
213
 | 
     my $col_comment = $column->comment;  | 
| 
421
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
422
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
299
 | 
     push @options, "data_type          => '" . $column->datatype . "',";  | 
| 
423
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
305
 | 
     push @options, "is_auto_increment  => 1,"                            if $column->autoincrement;  | 
| 
424
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
236
 | 
     push @options, "is_nullable        => 1,"                            if !$column->not_null;  | 
| 
425
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
292
 | 
     push @options, "size               => " . $size . ","                if $size > 0;  | 
| 
426
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
256
 | 
     push @options, "default_value      => '" . $default_value . "',"     if length $default_value;  | 
| 
427
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
428
 | 
88
 | 
  
100
  
 | 
 
 | 
  
381
  
 | 
 
 | 
494
 | 
     if ( first { $column->datatype eq $_ }qw/SMALLINT INT INTEGER BIGINT MEDIUMINT NUMERIC DECIMAL/ ) {  | 
| 
 
 | 
381
 | 
 
 | 
 
 | 
 
 | 
 
 | 
724
 | 
    | 
| 
429
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
95
 | 
         push @options, "is_numeric         => 1,";  | 
| 
430
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
431
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
432
 | 
88
 | 
  
100
  
 | 
 
 | 
  
98
  
 | 
 
 | 
389
 | 
     push @options, "retrieve_on_insert => 1," if first{ $name eq $_ }@{ $table->primary_key };  | 
| 
 
 | 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
255
 | 
    | 
| 
 
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
324
 | 
    | 
| 
433
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
326
 | 
     push @options, "is_foreign_key     => 1," if $foreign_keys->{$name};  | 
| 
434
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
435
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
152
 | 
     my %flags = %{ $column->flags };  | 
| 
 
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
284
 | 
    | 
| 
436
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
215
 | 
     if ( %flags ) {  | 
| 
437
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
         my $extras = join ', ', map { "$_ => 1" }sort keys %flags;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    | 
| 
438
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
         push @options, sprintf "extra => {%s},", $extras;  | 
| 
439
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
440
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
441
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
211
 | 
     my $column_comment_perl_raw = '';  | 
| 
442
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
443
 | 
88
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
531
 | 
     if ( ( $data && $data->{column_info}->{$name} ) || $col_comment ) {  | 
| 
 
 | 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
444
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
         local $Data::Dumper::Sortkeys = 1;  | 
| 
445
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
         local $Data::Dumper::Indent   = 1;  | 
| 
446
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
37
 | 
         local $Data::Dumper::Pad      = '      ';  | 
| 
447
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
448
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
88
 | 
         utf8::upgrade( $col_comment );  | 
| 
449
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
450
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
         my $comment_data;  | 
| 
451
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         eval {  | 
| 
452
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
249
 | 
             $comment_data = JSON->new->decode( $col_comment );  | 
| 
453
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
             1;  | 
| 
454
 | 
18
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
44
 | 
         } or do {  | 
| 
455
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
47
 | 
             if ( $col_comment =~ /\{/ ) {  | 
| 
456
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
75
 | 
             print STDERR $col_comment, ": ", $@;  | 
| 
457
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
458
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         };  | 
| 
459
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
460
 | 
18
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
120
 | 
         if ( !$comment_data || 'HASH' ne ref $comment_data ) {  | 
| 
461
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
             $column_comment_perl_raw = $col_comment;  | 
| 
462
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
60
 | 
             $comment_data            = {};  | 
| 
463
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
464
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         else {  | 
| 
465
 | 
6
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
49
 | 
             $column_comment_perl_raw = delete $comment_data->{comment} // '';  | 
| 
466
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
467
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
468
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         my %hash = (  | 
| 
469
 | 
18
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
104
 | 
             %{ $data->{column_info}->{$name} || {} },  | 
| 
470
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
55
 | 
             %{ $comment_data },  | 
| 
 
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
74
 | 
    | 
| 
471
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         );  | 
| 
472
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
473
 | 
18
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
75
 | 
         if ( %hash ) {  | 
| 
474
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
             my $dump = Dumper( \%hash );  | 
| 
475
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
578
 | 
             $dump    =~ s{\$VAR1 \s+ = \s* \{ \s*? $}{}xms;  | 
| 
476
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
             $dump    =~ s{\A\s+\n\s{8}}{}xms;  | 
| 
477
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
             $dump    =~ s{\n[ ]+\};\s*\z}{}xms;  | 
| 
478
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
479
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
             push @options, $dump;  | 
| 
480
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
481
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
482
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
483
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
273
 | 
     my $option_string = join "\n        ", @options;  | 
| 
484
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
485
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
273
 | 
     my @column_comment_lines = split /\r?\n/, $column_comment_perl_raw;  | 
| 
486
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
166
 | 
     my $column_comment_perl  = '';  | 
| 
487
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
488
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
191
 | 
     if ( @column_comment_lines ) {  | 
| 
489
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
         my $sep = sprintf "\n%s%s%s# ", ' ' x 4, ' ' x length $name, ' ' x 6;  | 
| 
490
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
46
 | 
         $column_comment_perl = ' # ' . join ( $sep, @column_comment_lines );  | 
| 
491
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
492
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
493
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
454
 | 
     my $details = sprintf "    %s => {%s\n        %s\n    },\n",  | 
| 
494
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $name,  | 
| 
495
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $column_comment_perl,  | 
| 
496
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $option_string;  | 
| 
497
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
498
 | 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
443
 | 
     return $details;  | 
| 
499
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
500
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
501
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _indexes_template {  | 
| 
502
 | 
92
 | 
 
 | 
 
 | 
  
92
  
 | 
 
 | 
6848
 | 
     my ($self, @indexes) = @_;  | 
| 
503
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
504
 | 
92
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
314
 | 
     return '' if !@indexes;  | 
| 
505
 | 
88
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
351
 | 
     return '' if $self->skip_indexes;  | 
| 
506
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
507
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
165
 | 
     my $hooks     = '';  | 
| 
508
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
147
 | 
     my $indexlist = '';  | 
| 
509
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
510
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
133
 | 
     my $unique_indexes = '';  | 
| 
511
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
512
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     INDEX:  | 
| 
513
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
203
 | 
     for my $index ( @indexes ) {  | 
| 
514
 | 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
364
 | 
         my $type = $index->type;  | 
| 
515
 | 
154
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
455
 | 
         $type    = 'normal' if !$type;  | 
| 
516
 | 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
331
 | 
         $type    = lc $type;  | 
| 
517
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
518
 | 
154
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
459
 | 
         next INDEX if $type eq 'primary';  | 
| 
519
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
520
 | 
72
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
222
 | 
         if ( $type eq 'unique' ) {  | 
| 
521
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $unique_indexes .= sprintf q~__PACKAGE__->add_unique_constraint(  | 
| 
522
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     %s => [qw/%s/],  | 
| 
523
 | 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
56
 | 
 );~, $index->name, ( join ' ', @{ $index->columns } );  | 
| 
 
 | 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
380
 | 
    | 
| 
524
 | 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
302
 | 
             next INDEX;  | 
| 
525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
526
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
527
 | 
51
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
208
 | 
         $type = 'normal' if $type eq 'index';  | 
| 
528
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
529
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $hooks .= sprintf '    $table->add_index(  | 
| 
530
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         type   => "%s",  | 
| 
531
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         name   => "%s",  | 
| 
532
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         fields => [%s],  | 
| 
533
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
534
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
535
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
179
 | 
 ', $type, $index->name, join ', ', map{ "'$_'" }@{ $index->columns };  | 
| 
 
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
786
 | 
    | 
| 
 
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
953
 | 
    | 
| 
536
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
537
 | 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
256
 | 
         $indexlist.= sprintf "=item * %s\n\n", $index->name;  | 
| 
538
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
539
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
540
 | 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
172
 | 
     my $sub_string = '';  | 
| 
541
 | 
85
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
244
 | 
     $sub_string .= $unique_indexes if $unique_indexes;  | 
| 
542
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
543
 | 
85
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
272
 | 
     return $sub_string if !$hooks;  | 
| 
544
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
545
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
223
 | 
     $sub_string .= qq~  | 
| 
546
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head1 DEPLOYMENT  | 
| 
547
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
548
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head2 sqlt_deploy_hook  | 
| 
549
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
550
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 These indexes are added to the table during deployment  | 
| 
551
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
552
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =over 4  | 
| 
553
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
554
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $indexlist  | 
| 
555
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
556
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =back  | 
| 
557
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
558
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =cut  | 
| 
559
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
560
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub sqlt_deploy_hook {  | 
| 
561
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my (\$self, \$table) = \@_;  | 
| 
562
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
563
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $hooks  | 
| 
564
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return 1;  | 
| 
565
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
566
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ~;  | 
| 
567
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
568
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
108
 | 
     return $sub_string;  | 
| 
569
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
570
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
571
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _main_template{  | 
| 
572
 | 
39
 | 
 
 | 
 
 | 
  
39
  
 | 
 
 | 
6242
 | 
     my ($self) = @_;  | 
| 
573
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
574
 | 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
80
 | 
     my @class_names = @{ $self->classes };  | 
| 
 
 | 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
176
 | 
    | 
| 
575
 | 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126
 | 
     my $classes     = join "\n", map{ "    " . $_ }@class_names;  | 
| 
 
 | 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
341
 | 
    | 
| 
576
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
577
 | 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
177
 | 
     my $schema_name = $self->schema_name;  | 
| 
578
 | 
39
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
159
 | 
     $schema_name    = '' if !defined $schema_name;  | 
| 
579
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
580
 | 
39
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
127
 | 
     if (!$schema_name) {  | 
| 
581
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
152
 | 
         my @schema_names = qw(DBIC_Schema Database DBIC MySchema MyDatabase DBIxClass_Schema);  | 
| 
582
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
583
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
72
 | 
         for my $schema ( @schema_names ){  | 
| 
584
 | 
31
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
70
 | 
             if( !grep{ $_ eq $schema }@class_names ){  | 
| 
 
 | 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
240
 | 
    | 
| 
585
 | 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
63
 | 
                 $schema_name = $schema;  | 
| 
586
 | 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
                 last;  | 
| 
587
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
588
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
589
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
590
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
591
 | 
39
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
326
 | 
     croak "couldn't determine a package name for the schema" unless $schema_name;  | 
| 
592
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
593
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
594
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
773
 | 
     $self->_set_schema_name( $schema_name );  | 
| 
595
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
596
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
502
 | 
     my $namespace  = $self->namespace . '::' . $schema_name;  | 
| 
597
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
141
 | 
        $namespace  =~ s/^:://;  | 
| 
598
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
599
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
77
 | 
     my $version;  | 
| 
600
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
62
 | 
     do {  | 
| 
601
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
132
 | 
         my $lib_path = $self->output_path;  | 
| 
602
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
192
 | 
         my @paths    = @INC;  | 
| 
603
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
116
 | 
         unshift @INC, $lib_path;  | 
| 
604
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
605
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2432
 | 
         eval "require $namespace";  | 
| 
606
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
582
 | 
         $version = $namespace->VERSION();  | 
| 
607
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     };  | 
| 
608
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
609
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
158
 | 
     my $custom_code;  | 
| 
610
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
325
 | 
     if ( $version ) {  | 
| 
611
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
         (my $path       = $namespace) =~ s{::}{/}g;  | 
| 
612
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
47
 | 
         my $schema_file = $self->output_path . '/' . $path . '.pm';  | 
| 
613
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
50
 | 
         $custom_code    = $self->_custom_code( $schema_file );  | 
| 
614
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
615
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
616
 | 
38
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
360
 | 
     $custom_code //= '';  | 
| 
617
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
618
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
     my %all_namespaces_to_load;  | 
| 
619
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
292
 | 
     if ( $self->resultset_namespace ) {  | 
| 
620
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
         push @{ $all_namespaces_to_load{resultset_namespace} }, sprintf "'%s'", $self->resultset_namespace;  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
47
 | 
    | 
| 
621
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
622
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
623
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
266
 | 
     if ( $self->load_resultset_namespace ) {  | 
| 
624
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
         push @{ $all_namespaces_to_load{resultset_namespace} }, map { "'$_'" }  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
    | 
| 
625
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             ref $self->load_resultset_namespace ?  | 
| 
626
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                 @{ $self->load_resultset_namespace } :  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
627
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 $self->load_resultset_namespace;  | 
| 
628
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
629
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
630
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
243
 | 
     if ( $self->load_result_namespace ) {  | 
| 
631
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
         push @{ $all_namespaces_to_load{result_namespace} }, map { "'$_'" }  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
    | 
| 
632
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             ref $self->load_result_namespace ?  | 
| 
633
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                 @{ $self->load_result_namespace } :  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
634
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 $self->load_result_namespace;  | 
| 
635
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
636
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
637
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
164
 | 
     if ( $self->result_namespace ) {  | 
| 
638
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
49
 | 
         my $namespace = sprintf "'%s::Result'", $self->result_namespace;  | 
| 
639
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
         my $found     = grep { $namespace eq $_ }@{ $all_namespaces_to_load{result_namespace} };  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
    | 
| 
 
 | 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
    | 
| 
640
 | 
12
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
36
 | 
         unshift @{ $all_namespaces_to_load{result_namespace} }, $namespace if !$found;  | 
| 
 
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
    | 
| 
641
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
642
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
643
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
164
 | 
     my $version_add = $self->version_add;  | 
| 
644
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
165
 | 
     $version_add    = 0.01 if !$version_add;  | 
| 
645
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
646
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
114
 | 
     if ( $version ) {  | 
| 
647
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32
 | 
         $version += $version_add;  | 
| 
648
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
649
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
650
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
124
 | 
     $version = $version_add if !$version;  | 
| 
651
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
652
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
145
 | 
     $self->_set_version( $version );  | 
| 
653
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
654
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
86
 | 
     my @namespace_types;  | 
| 
655
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
185
 | 
     for my $namespace_type ( sort keys %all_namespaces_to_load ) {  | 
| 
656
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
47
 | 
         my @namespaces = @{ $all_namespaces_to_load{$namespace_type} };  | 
| 
 
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
657
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
658
 | 
23
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
155
 | 
         push @namespace_types, sprintf "\n    %s => %s,",  | 
| 
659
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $namespace_type,  | 
| 
660
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             ( @namespaces == 1 ? $namespaces[0] : '[' . (join ', ', @namespaces ) . ']' );  | 
| 
661
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
662
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
663
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
120
 | 
     my $namespaces_to_load = '';  | 
| 
664
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
214
 | 
     $namespaces_to_load    = "(" . (join '', @namespace_types) . "\n)" if @namespace_types;  | 
| 
665
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
666
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
233
 | 
     my $use_utf8   = $self->utf8 ? "\nuse utf8;" : '';  | 
| 
667
 | 
38
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
244
 | 
     my $base_class = $self->schema_base_class ? $self->schema_base_class : 'DBIx::Class::Schema';   | 
| 
668
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
669
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
494
 | 
     my $template = qq~package $namespace;  | 
| 
670
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
671
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Schema class  | 
| 
672
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
673
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use strict;  | 
| 
674
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use warnings;$use_utf8  | 
| 
675
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
676
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use base qw/$base_class/;  | 
| 
677
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
678
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our \$VERSION = $version;  | 
| 
679
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
680
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __PACKAGE__->load_namespaces$namespaces_to_load;  | 
| 
681
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
682
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
683
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Put your own code below this comment  | 
| 
684
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
685
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $custom_code  | 
| 
686
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ---  | 
| 
687
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
688
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;~;  | 
| 
689
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
690
 | 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
220
 | 
     return $namespace, $template;  | 
| 
691
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
692
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
693
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
694
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
695
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
696
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |