Romani/Query/XML/SQL.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 84 CC 13 SCAR 32.9
CC
13
Cov
0%
create_value_from_node
56.0
create_function_from_node
30.0
create_where_from_node
12.0
CRAP 26.9
1  
2 package DBIx::Romani::Query::XML::SQL;
3  
4 use DBIx::Romani::Query::XML::Util;
5 use DBIx::Romani::Query::XML::TTT;
6 use DBIx::Romani::Query::XML::Where;
7 use DBIx::Romani::Query::XML::Function;
8 use DBIx::Romani::Query::Function::Count;
9 use strict;
10  
11 use Data::Dumper;
12  
13 sub create_value_from_node
14 {
15 my $node = shift;
16  
17 if ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY )
18 {
19 if ( $node->getTagName() eq 'ttt' )
20 {
21 if ( DBIx::Romani::Query::XML::TTT::get_node_type( $node ) eq 'func' )
22 {
23 return DBIx::Romani::Query::XML::TTT::create_ttt_from_node( $node );
24 }
25 }
26 elsif ( $node->getTagName() eq 'literal' )
27 {
28 return DBIx::Romani::Query::SQL::Literal->new( DBIx::Romani::Query::XML::Util::get_text( $node ) );
29 }
30 elsif ( $node->getTagName() eq 'column' )
31 {
32 # TODO: we should be able to set the table name
33 return DBIx::Romani::Query::SQL::Column->new( undef, DBIx::Romani::Query::XML::Util::get_text( $node ) );
34 }
35 }
36 elsif ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY_FUNCTION )
37 {
38 return DBIx::Romani::Query::XML::Function::create_function_from_node( $node );
39 }
40  
41 # Not a valid value!
42 return undef;
43 }
44  
45 sub create_function_from_node
46 {
47 my $node = shift;
48  
49 if ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY )
50 {
51 if ( $node->getTagName() eq 'ttt' )
52 {
53 if ( DBIx::Romani::Query::XML::TTT::get_node_type( $node ) eq 'func' )
54 {
55 return DBIx::Romani::Query::XML::TTT::create_ttt_from_node( $node );
56 }
57 }
58 }
59 elsif ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY_FUNCTION )
60 {
61 return DBIx::Romani::Query::XML::Function::create_function_from_node( $node );
62 }
63  
64 return undef;
65 }
66  
67 sub create_where_from_node
68 {
69 my $node = shift;
70  
71 if ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY and
72 $node->getTagName() eq 'ttt' )
73 {
74 return DBIx::Romani::Query::XML::TTT::create_ttt_from_node( $node );
75 }
76 elsif ( $node->getNamespaceURI() eq $DBIx::Romani::Query::XML::Util::NS_QUERY_OPERATOR )
77 {
78 return DBIx::Romani::Query::XML::Where::create_where_from_node( $node );
79 }
80 else
81 {
82 # if it is not any type of operator, it must be a value!
83 return create_value_from_node( $node );
84 }
85 }
86  
87 1;
88