Index: lib/active_record/connection_adapters/sqlite_adapter.rb =================================================================== --- lib/active_record/connection_adapters/sqlite_adapter.rb (revision 9273) +++ lib/active_record/connection_adapters/sqlite_adapter.rb (revision 9274) @@ -208,7 +208,7 @@ def columns(table_name, name = nil) #:nodoc: table_structure(table_name).map do |field| - SQLiteColumn.new(field['name'], field['dflt_value'], field['type'], field['notnull'] == "0") + SQLiteColumn.new(field['name'], default_value(field['dflt_value']), field['type'], field['notnull'] == "0") end end @@ -353,6 +353,10 @@ raise end end + + def default_value(value) + value + end end class SQLite3Adapter < SQLiteAdapter # :nodoc: @@ -361,6 +365,19 @@ raise ActiveRecord::StatementInvalid if structure.empty? end end + + protected + def default_value(value) + # String values + return $1 if value =~ /^'(.*)'/ + + # Numeric values + return value if value =~ /^-?[0-9]+(\.[0-9]*)?/ + + # Anything else is blank, some user type, or some function + # and we can't know the value of that, so return nil. + return nil + end end class SQLite2Adapter < SQLiteAdapter # :nodoc: