File Coverage

blib/lib/SQL/ReservedWords/SQLite.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 10 10 100.0
pod 5 5 100.0
total 45 45 100.0


line stmt bran cond sub pod time code
1             package SQL::ReservedWords::SQLite;
2              
3 2     2   2912 use strict;
  2         6  
  2         79  
4 2     2   12 use warnings;
  2         4  
  2         74  
5 2     2   10 use vars '$VERSION';
  2         4  
  2         130  
6              
7             $VERSION = '0.8';
8              
9 2     2   12 use constant SQLITE2 => 0x01; # 2.8.17
  2         4  
  2         111  
10 2     2   10 use constant SQLITE3 => 0x02; # 3.3.4
  2         3  
  2         6875  
11              
12             {
13             require Sub::Exporter;
14              
15             my @exports = qw[
16             is_reserved
17             is_reserved_by_sqlite2
18             is_reserved_by_sqlite3
19             reserved_by
20             words
21             ];
22              
23             Sub::Exporter->import( -setup => { exports => \@exports } );
24             }
25              
26             {
27             my %WORDS = (
28             ALL => SQLITE2 | SQLITE3,
29             ALTER => SQLITE3,
30             AND => SQLITE2 | SQLITE3,
31             AS => SQLITE2 | SQLITE3,
32             AUTOINCREMENT => SQLITE3,
33             BETWEEN => SQLITE2 | SQLITE3,
34             BY => SQLITE2 | SQLITE3,
35             CASE => SQLITE2 | SQLITE3,
36             CHECK => SQLITE2 | SQLITE3,
37             COLLATE => SQLITE2 | SQLITE3,
38             COMMIT => SQLITE2 | SQLITE3,
39             CONSTRAINT => SQLITE2 | SQLITE3,
40             CREATE => SQLITE2 | SQLITE3,
41             CROSS => SQLITE3,
42             DEFAULT => SQLITE2 | SQLITE3,
43             DEFERRABLE => SQLITE2 | SQLITE3,
44             DELETE => SQLITE2 | SQLITE3,
45             DISTINCT => SQLITE2 | SQLITE3,
46             DROP => SQLITE2 | SQLITE3,
47             ELSE => SQLITE2 | SQLITE3,
48             ESCAPE => SQLITE3,
49             EXCEPT => SQLITE2 | SQLITE3,
50             FOREIGN => SQLITE2 | SQLITE3,
51             FROM => SQLITE2 | SQLITE3,
52             FULL => SQLITE3,
53             GLOB => SQLITE2,
54             GROUP => SQLITE2 | SQLITE3,
55             HAVING => SQLITE2 | SQLITE3,
56             IN => SQLITE2 | SQLITE3,
57             INDEX => SQLITE2 | SQLITE3,
58             INNER => SQLITE3,
59             INSERT => SQLITE2 | SQLITE3,
60             INTERSECT => SQLITE2 | SQLITE3,
61             INTO => SQLITE2 | SQLITE3,
62             IS => SQLITE2 | SQLITE3,
63             ISNULL => SQLITE2 | SQLITE3,
64             JOIN => SQLITE2 | SQLITE3,
65             LEFT => SQLITE3,
66             LIKE => SQLITE2,
67             LIMIT => SQLITE2 | SQLITE3,
68             NATURAL => SQLITE3,
69             NOT => SQLITE2 | SQLITE3,
70             NOTNULL => SQLITE2 | SQLITE3,
71             NULL => SQLITE2 | SQLITE3,
72             ON => SQLITE2 | SQLITE3,
73             OR => SQLITE2 | SQLITE3,
74             ORDER => SQLITE2 | SQLITE3,
75             OUTER => SQLITE3,
76             PRIMARY => SQLITE2 | SQLITE3,
77             REFERENCES => SQLITE2 | SQLITE3,
78             RIGHT => SQLITE3,
79             ROLLBACK => SQLITE2 | SQLITE3,
80             SELECT => SQLITE2 | SQLITE3,
81             SET => SQLITE2 | SQLITE3,
82             TABLE => SQLITE2 | SQLITE3,
83             THEN => SQLITE2 | SQLITE3,
84             TO => SQLITE3,
85             TRANSACTION => SQLITE2 | SQLITE3,
86             UNION => SQLITE2 | SQLITE3,
87             UNIQUE => SQLITE2 | SQLITE3,
88             UPDATE => SQLITE2 | SQLITE3,
89             USING => SQLITE2 | SQLITE3,
90             VALUES => SQLITE2 | SQLITE3,
91             WHEN => SQLITE2 | SQLITE3,
92             WHERE => SQLITE2 | SQLITE3,
93             );
94              
95             sub is_reserved {
96 20   100 20 1 152 return $WORDS{ uc(pop || '') } || 0;
97             }
98              
99             sub is_reserved_by_sqlite2 {
100 5     5 1 12 return &is_reserved & SQLITE2;
101             }
102              
103             sub is_reserved_by_sqlite3 {
104 5     5 1 16 return &is_reserved & SQLITE3;
105             }
106              
107             sub reserved_by {
108 4     4 1 9 my $flags = &is_reserved;
109 4         5 my @reserved_by = ();
110              
111 4 100       14 push @reserved_by, 'SQLite 2' if $flags & SQLITE2;
112 4 100       12 push @reserved_by, 'SQLite 3' if $flags & SQLITE3;
113              
114 4         21 return @reserved_by;
115             }
116              
117             sub words {
118 2     2 1 8306 return sort keys %WORDS;
119             }
120             }
121              
122             1;
123              
124             __END__