ruby-win32/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1-x86-mswin32/lib/sqlite3/translator.rb
# Register the default translators for the current Translator instance.
# This includes translators for most major SQL data types.
Register the default translators for the current Translator instance.
This includes translators for most major SQL data types.
Register the default translators for the current Translator instance . This includes translators for most major SQL data types .
def register_default_translators
      [ "date",
        "datetime",
        "time" ].each { |type| add_translator( type ) { |t,v| Time.parse( v ) } }
      [ "decimal",
        "float",
        "numeric",
        "double",
        "real",
        "dec",
        "fixed" ].each { |type| add_translator( type ) { |t,v| v.to_f } }
      [ "integer",
        "smallint",
        "mediumint",
        "int",
        "bigint" ].each { |type| add_translator( type ) { |t,v| v.to_i } }
      [ "bit",
        "bool",
        "boolean" ].each do |type|
        add_translator( type ) do |t,v|
          !( v.strip.gsub(/00+/,"0") == "0" ||
             v.downcase == "false" ||
             v.downcase == "f" ||
             v.downcase == "no" ||
             v.downcase == "n" )
        end
      end
      add_translator( "timestamp" ) { |type, value| Time.at( value.to_i ) }
      add_translator( "tinyint" ) do |type, value|
        if type =~ /\(\s*1\s*\)/
          value.to_i == 1
        else
          value.to_i
        end
      end
    end
def register_default_translators [ "date" , "datetime" , "time" ] . each { | type | add_translator ( type ) { | t , v | Time . parse ( v ) } } [ "decimal" , "float" , "numeric" , "double" , "real" , "dec" , "fixed" ] . each { | type | add_translator ( type ) { | t , v | v . to_f } } [ "integer" , "smallint" , "mediumint" , "int" , "bigint" ] . each { | type | add_translator ( type ) { | t , v | v . to_i } } [ "bit" , "bool" , "boolean" ] . each do | type | add_translator ( type ) do | t , v | ! ( v . strip . gsub ( / 00+ / , "0" ) == "0" || v . downcase == "false" || v . downcase == "f" || v . downcase == "no" || v . downcase == "n" ) end end add_translator ( "timestamp" ) { | type , value | Time . at ( value . to_i ) } add_translator ( "tinyint" ) do | type , value | if type =~ / \( \s *1 \s * \) / value . to_i == 1 else value . to_i end end end
Register the default translators for the current Translator instance.
Register the default translators for the current Translator instance .