[CDBI] column case sensitivity (Pg)

Erik Sluiters e.c.sluiters at med.uu.nl
Tue Aug 22 11:34:53 BST 2006

Hi all,
The postgres database i work on unfortunatly makes use of case sensitive 
column names. It was a wrong database design decision (not by me thankfully), 
i wish i could just change column names but it just breaks too much in the 
interface to do. 
I'm really impressed by the functionality of ClassDBI but unfortunatly 
ClassDBI doesn't work with column names with uppercases in it. I took a peek 
at the ClassDBI code and found that it is quite trivial to make it work with 
case sensitive column names, basically i just removed all conversions to 
I've listed the changes below, unless there is a good reason to have ClassDBI 
only work with lowercase column names maybe this could be incorporated in the 
main branch of ClassDBI? That way anyone can have a lousily designed database 
and still use ClassDBI...
Kind regards,

Code changes:

*** Class/DBI.pm
- on line 385 in sub _mk_column_accessors add
( my $objName = $obj->name ) =~ s/\"//g; 

- line 388 & 389 in sub _mk_column_accessors
ro => $obj->accessor($class->accessor_name($obj->name)),
wo => $obj->mutator($class->mutator_name($obj->name)),
- change to
ro => $obj->accessor($class->accessor_name($objName)),
wo => $obj->mutator($class->mutator_name($objName)),

- line 393 in sub _mk_column_accessors
my $accessor = $class->$acc_type($obj->name_lc);
- change to
my $accessor = $class->$acc_type($obj->name);

- line 408 in sub _make_method
$class->_make_method(lc $name => $method);
- change to
$class->_make_method($name => $method);

*** Class/DBI/Column.pm
- line 37 after 'use overload'
'""'     => sub { shift->name_lc }
- change to
'""'     => sub { shift->name }

*** Class/DBI/ColumnGrouper.pm:
- line 83 in sub add_column
$self->{_allcol}->{ lc $name } ||= Class::DBI::Column->new($name);
- change to
$self->{_allcol}->{ $name } ||= Class::DBI::Column->new($name);

- line 89 in sub find_column
return unless $self->{_allcol}->{ lc $name };
- change to
return unless $self->{_allcol}->{ $name };

More information about the ClassDBI mailing list