Document/Templates/Tools/Generate/SQL.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 56 CC 6 SCAR 33.6
CC
6
Cov
0%
length_default_calc
42.0
set_subs
2.0
BEGIN
2.0
CRAP 28.7
1 package Daje::Document::Templates::Tools::Generate::SQL;
2 use Mojo::Base 'Daje::Document::Templates::Base', -base;
3 use v5.42;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Templates::Tools::Generate::SQL; - It creates sql code
9 #
10 # SYNOPSIS
11 # ========
12 #
13 # use Daje::Templates::Tools::Generate::SQL;
14 #
15 # Provides a method for the template to be loaded into the data structure
16 #
17 # sub length_default_calc($self) returns a sub for setting details in template.
18 #
19 #
20 # DESCRIPTION
21 # ===========
22 #
23 # Daje::Templates::Tools::Generate::SQL; is a module that retrieves data from a View
24 #
25 # LICENSE
26 # =======
27 #
28 # Copyright (C) janeskil1525.
29 #
30 # This library is free software; you can redistribute it and/or modify
31 # it under the same terms as Perl itself.
32 #
33 # AUTHOR
34 # ======
35 #
36 # janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
37 #
38  
39 sub set_subs($self) {
40 $self->subs(('length_default_calc'));
41 }
42  
43  
44 sub length_default_calc($self) {
45 return sub {
46 my $length = $_[0];
47 my $scale = $_[1];
48 my $notnull = $_[2];
49 my $default = $_[3];
50 my $unique = $_[4];
51 my $result = "";
52 if ($length > 0 and $scale > 0) {
53 $result = "($length, $scale)";
54 }
55 elsif ($length > 0 and $scale == 0) {
56 $result = "($length)";
57 }
58 if($unique == 1) {
59 $result .= " UNIQUE ";
60 }
61 if ($notnull == 1) {
62 $result .= " NOT NULL ";
63 $result .= "DEFAULT $default " if (defined $default and length($default) > 0);
64 }
65  
66 return $result;
67 };
68 }
69 1;
70  
71 __DATA__