[PATCH] using Class::DBI with Sybase

[prev] [thread] [next] [Date index for 2005/02/21]

From: ivor.williams
Subject: [PATCH] using Class::DBI with Sybase
Date: 17:58 on 21 Feb 2005
This fixes a couple of problems:

1. Mixed case columns. Sybase column names are case sensitive. I have a database with studlyCapsColumns, which to date I have not been able to use with cDBI. See also RT ticket #3814:
http://rt.cpan.org/NoAuth/Bug.html?id=3814

2. Statement handle is "Active" but query has not been run and no column information is available.

To make it behave right with Sybase, you need to set 

$Class::DBI::Column::FetchHashKeyName = 'NAME'

somewhere in BEGIN. This may be a kludge, but I await a solution in the next version :).

Ivor.

========================================
--- lib/Class/DBI.pm.orig 
+++ lib/Class/DBI.pm 
@@ -1125,6 +1125,11 @@
                $sth->bind_columns(\(@data{ @{ $sth->{NAME_lc} } }));
                push @rows, {%data} while $sth->fetch;
        };
+       eval {
+               $sth->execute(@$args);
+               $sth->bind_columns(\(@data{ @{ $sth->{NAME_lc} } }));
+               push @rows, {%data} while $sth->fetch;
+       } if $@;
        return $class->_croak("$class can't $sth->{Statement}: $@", err => $@)
                if $@;
        return $class->_ids_to_objects(\@rows);

========================================
--- lib/Class/DBI/Column.pm.orig
+++ lib/Class/DBI/Column.pm
@@ -56,7 +56,20 @@
        );
 }
 
-sub name_lc { lc shift->name }
+our $FetchHashKeyName = 'NAME_lc';
+ 
+sub name_lc { 
+       my $name = shift->name;
+       if ($FetchHashKeyName eq 'NAME_lc') {
+               lc $name;
+       }
+       elsif ($FetchHashKeyName eq 'NAME_uc') {
+               uc $name;
+       }
+       else {
+               $name;
+       }
+ }
 
 sub add_group {
        my ($self, $group) = @_;
========================================

[PATCH] using Class::DBI with Sybase
ivor.williams 17:58 on 21 Feb 2005

Re: [PATCH] using Class::DBI with Sybase
Tony Bowden 19:01 on 21 Feb 2005

Re: [PATCH] using Class::DBI with Sybase
ivor.williams 12:04 on 22 Feb 2005

Re: [PATCH] using Class::DBI with Sybase
ivor.williams 13:59 on 03 Mar 2005

Re: [PATCH] using Class::DBI with Sybase
Johan Lindstrom 17:51 on 03 Mar 2005

RE: [PATCH] using Class::DBI with Sybase
Addison, Mark 20:00 on 21 Feb 2005

Generated at 00:32 on 04 Mar 2005 by mariachi v0.52