From: Chris W. <ch...@cw...> - 2002-10-03 21:22:31
|
On Thu, 2002-10-03 at 13:43, Ray Zimmerman wrote: > At 11:19 AM -0400 10/3/02, Chris Winters wrote: > > # keys \%dbi_types = ( 'foo', 'bar', 'baz' ) > > foreach my $field ( @{ $fields } ) { > > my $field_type = $dbi_types->{ $field }; # uh oh, type not found! > > } > > So that last line currently needs to be ... > > my $field_type = $dbi_types->{ lc $field }; > > ... in order to find the type, right? Correct. > Well, I suppose that would "fix" it. The reason it appeared as a > "bug" to me is that I always use consistent case between the SPOPS > config and the names in the database (which I thought should be as > safe as you can get), but we ran into problems with the > db_discover_types because it was returning a hash with lc'd keys. > > I would prefer things being case sensitive everywhere, like a regular > Perl hash, but since SQL (or at least mysql) has case-insensitive > column names, I guess that's not a reasonable option. Shoot, while we're changing it why don't we just make it an object: my $type_info = $spops_class->db_discover_types; my $dbi_type = $type_info->get_type( $field ); That would probably be the simplest and most explicit thing -- it's obvious what it does, and in the implementation 'get_type' wouldn't care what case $field was in. I don't think there'd be much more overhead than now, since we only keep one copy of the type information around anyway. What do you think? Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |