blib/lib/NoSQL/PL2SQL/DBI/MySQL.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« PL2SQL.xs ↑ Summary
1 package NoSQL::PL2SQL::DBI::MySQL ;
2 1 ▶use base qw( NoSQL::PL2SQL::DBI ) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 ## The following methods construct SQL messages and may need to be modified
5 ## for different implementations
6  
7 # sub fetch {}
8 # sub update {}
9 # sub delete {}
10 # sub lastinsertid {}
11  
12 ###############################################################################
13 ##
14 ## Schema: NoSQL::PL2SQL::DBI::MySQL
15 ## Base Schema: NoSQL::PL2SQL::DBI
16 ## Schema Node: NoSQL::PL2SQL::DBI::MySQL::table::column
17 ## Base Schema Node: NoSQL::PL2SQL::DBI::table::column
18 ##
19 ## The schema method is called for every node in the XML definition. The
20 ## base schema class is called on the top node, and any node without a
21 ## schema class definition.
22 ##
23 ## If a Schema Node class is undefined altogether, the inheritance order is
24 ## as follows:
25 ## Base Schema Node
26 ## Schema
27 ## Base Schema
28 ##
29 ## If a Schema Node class is defined, but the schema() method is not,
30 ## inheritance drops immediately to the Base Schema. The default schema()
31 ## method, defined in the Base Schema, returns the schema results of its
32 ## child nodes. Therefore, definitions are only required from the lowest
33 ## level nodes containing the relevant data.
34 ##
35 ###############################################################################
36  
37  
38 package NoSQL::PL2SQL::DBI::MySQL::Schema ;
39 use base qw( NoSQL::PL2SQL::DBI::Schema ) ;
40  
41 ## A Schema class must be defined although the base methods should always
42 ## be adequate.
43  
44 ## No need to override.
45 # sub schema {
46 # my $self = shift ;
47 # }
48  
49 package NoSQL::PL2SQL::DBI::MySQL::Schema::table ;
50 use base qw( NoSQL::PL2SQL::DBI::Schema ) ;
51  
52 sub schema {
53 my $self = shift ;
54 return $self->command
55 || NoSQL::PL2SQL::DBI::Schema->schema( $self ) ;
56 }
57  
58 sub CREATE {
59 my $self = shift ;
60 my $elements = {} ;
61  
62 my @terms = () ;
63 push @terms, $self->getattributes->{command}, 'TABLE' ;
64 push @terms, $self->getattributes->{table} ;
65 push @terms, sprintf '( %s )', join ', ',
66 NoSQL::PL2SQL::DBI::Schema->schema( $self ) ;
67  
68 return join ' ', @terms ;
69 }
70  
71 package NoSQL::PL2SQL::DBI::MySQL::Schema::table::column ;
72 use base qw( NoSQL::PL2SQL::DBI::Schema ) ;
73  
74 sub schema {
75 my $self = shift ;
76  
77 my @terms = () ;
78 my $attribs = $self->getattributes ;
79  
80 push @terms, $attribs->{name} ;
81 push @terms, $attribs->{type} if exists $attribs->{type} ;
82 $terms[-1] .= sprintf '(%d)', $attribs->{length}
83 if exists $attribs->{length} ;
84  
85 push @terms, $self->taglist ;
86 return join ' ', @terms ;
87 }
88  
89 package NoSQL::PL2SQL::DBI::MySQL::Schema::index ;
90 use base qw( NoSQL::PL2SQL::DBI::Schema ) ;
91  
92 sub schema {
93 my $self = shift ;
94 return $self->command
95 || NoSQL::PL2SQL::DBI::Schema->schema( $self ) ;
96 }
97  
98 sub CREATE {
99 my $self = shift ;
100  
101 my @terms = () ;
102 push @terms, $self->getattributes->{command}, 'INDEX' ;
103 push @terms, $self->getattributes->{name} ;
104 return () unless $self->getattributes->{table} ;
105 push @terms, ( ON => $self->getattributes->{table} ) ;
106 push @terms, sprintf '( %s )', join ', ',
107 NoSQL::PL2SQL::DBI::Schema->schema( $self ) ;
108  
109 return join ' ', @terms ;
110 }
111  
112 package NoSQL::PL2SQL::DBI::MySQL::Schema::index::column ;
113 use base qw( NoSQL::PL2SQL::DBI::MySQL::Schema::table::column ) ;
114  
115 1;
116 __END__
« PL2SQL.xs ↑ Summary