Update of /cvsroot/ruby-dbi/src/lib/dbi
In directory sc8-pr-cvs1:/tmp/cvs-serv23097
Modified Files:
dbi.rb
Log Message:
Fix bug in case insensitive driver name lookup on case insensitive filesystems
Index: dbi.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbi/dbi.rb,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- dbi.rb 22 Oct 2002 15:06:04 -0000 1.35
+++ dbi.rb 8 Feb 2003 02:26:15 -0000 1.36
@@ -460,8 +460,25 @@
end
found ||= driver_name
+
+ # On a filesystem that is not case-sensitive (e.g., HFS+ on Mac OS X),
+ # the initial require attempt that loads the driver may succeed even
+ # though the lettercase of driver_name doesn't match the actual
+ # filename. If that happens, const_get will fail and it become
+ # necessary to look though the list of constants and look for a
+ # caseless match. The result of this match provides the constant
+ # with the proper lettercase -- which can be used to generate the
+ # driver handle.
- dr = DBI::DBD.const_get(found.intern)
+ dr = nil
+ begin
+ dr = DBI::DBD.const_get(found.intern)
+ rescue NameError
+ # caseless look for constants to find actual constant
+ found = found.downcase
+ found = DBI::DBD.constants.find { |e| e.downcase == found }
+ dr = DBI::DBD.const_get(found.intern) unless found.nil?
+ end
dbd_dr = dr::Driver.new
drh = DBI::DriverHandle.new(dbd_dr)
drh.trace(@@trace_mode, @@trace_output)
|