SearchBuilder/Handle/Sybase.pm

filter: Statementstmt 22.7% 10 / 44 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 3 / 9 Podpod 100% 6 / 6 totaltotal 28.3% 19 / 67 CC 5 SCAR 20.7
CC
5
Cov
19%
Insert
20.0
DistinctQuery
6.0
DatabaseVersion
2.0
CRAP 7.9
« SearchBuilder/Handle/SQLite.pm ↑ Summary SearchBuilder/Unique.pm »
1 package DBIx::SearchBuilder::Handle::Sybase;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base qw(DBIx::SearchBuilder::Handle);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 DBIx::SearchBuilder::Handle::Sybase -- a Sybase specific Handle object
11  
12 =head1 SYNOPSIS
13  
14  
15 =head1 DESCRIPTION
16  
17 This module provides a subclass of DBIx::SearchBuilder::Handle that
18 compensates for some of the idiosyncrasies of Sybase.
19  
20 =head1 METHODS
21  
22 =cut
23  
24  
25 =head2 Insert
26  
27 Takes a table name as the first argument and assumes that the rest of the arguments
28 are an array of key-value pairs to be inserted.
29  
30 If the insert succeeds, returns the id of the insert, otherwise, returns
31 a Class::ReturnValue object with the error reported.
32  
33 =cut
34  
35 0 ▶sub Insert {
Subroutine Insert: not called CC=4 SCAR=30.0
Pod documented
36 0 my $self = shift;
37  
38 0 my $table = shift;
39 0 my %pairs = @_;
40 0 my $sth = $self->SUPER::Insert( $table, %pairs );
41 0 ▶ if ( !$sth ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth) 0 0 0
42 0 return ($sth);
43 }
44  
45 # Can't select identity column if we're inserting the id by hand.
46 0 ▶ unless ($pairs{'id'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pairs{"id"}) 0 0 0
47 0 my @row = $self->FetchResult('SELECT @@identity');
48  
49 # TODO: Propagate Class::ReturnValue up here.
50 0 ▶ unless ( $row[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($row[0]) 0 0 0
51 0 return (undef);
52 }
53 0 $self->{'id'} = $row[0];
54 }
55 0 return ( $self->{'id'} );
56 }
57  
58  
59  
60  
61  
62 =head2 DatabaseVersion
63  
64 return the database version, trimming off any -foo identifier
65  
66 =cut
67  
68 0 ▶sub DatabaseVersion {
Subroutine DatabaseVersion: not called CC=1 SCAR=6.9
Pod documented
69 0 my $self = shift;
70 0 my $v = $self->SUPER::DatabaseVersion();
71  
72 0 $v =~ s/\-(.*)$//;
73 0 return ($v);
74 }
75  
76 =head2 CaseSensitive
77  
78 Returns undef, since Sybase's searches are not case sensitive by default
79  
80 =cut
81  
82 0 ▶sub CaseSensitive {
Subroutine CaseSensitive: not called CC=1 SCAR=6.9
Pod documented
83 0 my $self = shift;
84 0 return(1);
85 }
86  
87  
88  
89  
90 0 ▶sub ApplyLimits {
Subroutine ApplyLimits: not called CC=1 SCAR=6.9
Pod documented
91 0 my $self = shift;
92 0 my $statementref = shift;
93 0 my $per_page = shift;
94 0 my $first = shift;
95  
96 }
97  
98  
99 =head2 DistinctQuery STATEMENTREFtakes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
100  
101  
102 =cut
103  
104 0 ▶sub DistinctQuery {
Subroutine DistinctQuery: not called CC=2 SCAR=17.9
Pod documented
105 0 my $self = shift;
106 0 my $statementref = shift;
107 0 my $sb = shift;
108 0 my $table = $sb->Table;
109  
110 0 ▶ if ($sb->_OrderClause =~ /(?<!main)\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sb->_OrderClause =~ /(?<!main)\./) { } 0 0 0
111 # Don't know how to do ORDER BY when the DISTINCT is in a subquery
112 0 warn "Query will contain duplicate rows; don't how how to ORDER BY across DISTINCT";
113 0 $$statementref = "SELECT main.* FROM $$statementref";
114 } else {
115 # Wrapper select query in a subselect as Sybase doesn't allow
116 # DISTINCT against CLOB/BLOB column types.
117 0 $$statementref = "SELECT main.* FROM ( SELECT DISTINCT main.id FROM $$statementref ) distinctquery, $table main WHERE (main.id = distinctquery.id) ";
118 }
119 0 $$statementref .= $sb->_GroupClause;
120 0 $$statementref .= $sb->_OrderClause;
121 }
122  
123  
124 =head2 BinarySafeBLOBs
125  
126 Return undef, as Oracle doesn't support binary-safe CLOBS
127  
128  
129 =cut
130  
131 0 ▶sub BinarySafeBLOBs {
Subroutine BinarySafeBLOBs: not called CC=1 SCAR=6.9
Pod documented
132 0 my $self = shift;
133 0 return(undef);
134 }
135  
136 1 1;
« SearchBuilder/Handle/SQLite.pm ↑ Summary SearchBuilder/Unique.pm »