Restore DBD::MySQL::Database#quote method

For whatever reason, Ruby DBI and DBD have axed the quote method from their midst, breaking compatibility with previous versions. Sadly I couldn’t find any clues as to why it was removed (actually, bluntly commented out).

Fortunately I was able to unearth some hints how to restore this method and with an added fix to NilClass, the result seems to be working fine:

# For some unknown reason quote method is commented out at:
# Restoring it for b/w compliance
module DBI::DBD::Mysql
  class Database < DBI::BaseDatabase
    def quote(value)
        case value
        when String
        when DBI::Binary
        when TrueClass
        when FalseClass
        when Array
          value.collect { |v| quote(v) }.join(", ")
        when DBI::Date, DBI::Time, DBI::Timestamp, ::Date
        when ::Time
        when NilClass

Just place this in some file and require it in your code.