File Coverage

blib/lib/DBIx/SearchBuilder/Handle/Sybase.pm
Criterion Covered Total %
statement 9 43 20.9
branch 0 8 0.0
condition n/a
subroutine 3 9 33.3
pod 6 6 100.0
total 18 66 27.2


line stmt bran cond sub pod time code
1             package DBIx::SearchBuilder::Handle::Sybase;
2              
3 1     1   984 use strict;
  1         7  
  1         28  
4 1     1   6 use warnings;
  1         2  
  1         25  
5              
6 1     1   15 use base qw(DBIx::SearchBuilder::Handle);
  1         10  
  1         504  
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             sub Insert {
36 0     0 1   my $self = shift;
37              
38 0           my $table = shift;
39 0           my %pairs = @_;
40 0           my $sth = $self->SUPER::Insert( $table, %pairs );
41 0 0         if ( !$sth ) {
42 0           return ($sth);
43             }
44              
45             # Can't select identity column if we're inserting the id by hand.
46 0 0         unless ($pairs{'id'}) {
47 0           my @row = $self->FetchResult('SELECT @@identity');
48              
49             # TODO: Propagate Class::ReturnValue up here.
50 0 0         unless ( $row[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             sub DatabaseVersion {
69 0     0 1   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             sub CaseSensitive {
83 0     0 1   my $self = shift;
84 0           return(1);
85             }
86              
87              
88              
89              
90             sub ApplyLimits {
91 0     0 1   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             sub DistinctQuery {
105 0     0 1   my $self = shift;
106 0           my $statementref = shift;
107 0           my $sb = shift;
108 0           my $table = $sb->Table;
109              
110 0 0         if ($sb->_OrderClause =~ /(?
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             sub BinarySafeBLOBs {
132 0     0 1   my $self = shift;
133 0           return(undef);
134             }
135              
136             1;