Sybase/Quote.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 95.6% 44 / 46 CC 5 SCAR 10.7
CC
5
Cov
97%
quote_ident
5.0
keywords
2.0
BEGIN
1.0
CRAP 2.9
« Sybase/Storage/ASE/NoBindVars.pm ↑ Summary Sybase/Storage/FreeTDS.pm »
1 package DBIO::Sybase::Quote;
2 # ABSTRACT: Quote an identifier the way Sybase ASE reads it
3  
4 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 41 our $VERSION = '0.900007';
8  
9 41 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 41 ▶use DBIO::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 41 our @EXPORT_OK = qw(quote_ident is_keyword keywords);
12  
13  
14  
15 41 our %KEYWORD = map { $_ => 1 } qw(
16 add all alter and any arith_overflow as asc at authorization avg begin
17 between break browse bulk by called cascade case char_convert check
18 checkpoint close clustered coalesce commit compressed compute confirm
19 connect constraint continue controlrow convert count count_big create
20 current cursor database dbcc deallocate declare decrypt decrypt_default
21 default delete desc deterministic disk distinct drop dual_control dummy
22 dump else encrypt end endtran errlvl errordata errorexit escape except
23 exclusive exec execute exists exit exp_row_size external fetch
24 fillfactor for foreign from goto grant group having holdlock identity
25 identity_gap identity_insert identity_start if in index inout
26 insensitive insert install intersect into is isolation jar join key kill
27 level like lineno load lob_compression lock log manage materialized max
28 max_rows_per_page min mirror mirrorexit modify national noholdlock
29 nonclustered not null nullif numeric_truncation of off offsets on once
30 online only open option or order out output over partition perm
31 permanent plan prepare primary print privileges proc procedure
32 processexit proxy_table public quiesce raiserror read readpast readtext
33 reconfigure references release_locks_on_close remove reorg replace
34 replication reservepagegap return returns revoke role rollback rowcount
35 rows rule save schema scroll select semi_sensitive set setuser shared
36 shutdown some statistics stringsize stripe sum syb_identity syb_restree
37 syb_terminate table temp temporary textsize to tracefile tran
38 transaction trigger truncate tsequal union unique unpartition unsigned
39 update use user user_option using values varying view waitfor when where
40 while with work writetext xmlextract xmlparse xmltable xmltest
41 );
42  
43  
44 0 ▶sub keywords { sort keys %KEYWORD }
Subroutine keywords: not called CC=1 SCAR=6.9
Pod documented
45  
46  
47  
48 1055 ▶sub is_keyword { exists $KEYWORD{ lc $_[0] } }
Subroutine is_keyword: called CC=1 SCAR=0.0
Pod documented
49  
50  
51 1064 ▶sub quote_ident {
Subroutine quote_ident: called CC=5 SCAR=16.1
Pod documented
52 1064 my ($name) = @_;
53 1064 ▶ DBIO::Exception->throw(sprintf
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[#@]/ 2 1062 1064
54 q{DBIO::Sybase: cannot write the name '%s' as an identifier: a name starting with # or @ is a temporary table or a variable to ASE, which refuses it as the name of a table, column or index even in brackets (Msg 11717, 16366)},
55 $name) if $name =~ /\A[#@]/;
56 1062 ▶ DBIO::Exception->throw(sprintf
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\./ 5 1057 1062
57 q{DBIO::Sybase: cannot write the name '%s' as an identifier: ASE reads a dot as owner.name, also inside brackets (Msg 2734), so it cannot be part of a name and a name with a dot is refused},
58 $name) if $name =~ /\./;
59 1057 ▶ return $name if $name =~ /\A[a-z_][a-z0-9_]*\z/i and not is_keyword($name);
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[a-z_][a-z0-9_]*\z/i and not is_keyword($name) 995 62 1057
Condition100%3/3
$name =~ /\A[a-z_][a-z0-9_]*\z/i and not is_keyword($name)
!ll&&!rl&&r
656995
MC/DC100%2/2
$name =~ /\A[a-z_][a-z0-9_]*\z/i and not is_keyword($name)
$name =~ /\A[a-z_][a-z0-9_]*\z/i not is_keyword($name)
Truth table100%3/3
A and not(B)
A= $name =~ /\A[a-z_][a-z0-9_]*\z/iB= not is_keyword($name)
ABresult
0X0
100
111
60 62 (my $q = $name) =~ s/\]/]]/g;
61 62 return "[$q]";
62 }
63  
64 41 1;
65  
66 __END__
« Sybase/Storage/ASE/NoBindVars.pm ↑ Summary Sybase/Storage/FreeTDS.pm »