diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-05-04 19:01:24 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-01-13 22:03:56 +0900 |
commit | 744552f72d49c222d6cc42ab8bad9a16a812377a (patch) | |
tree | 3aa27a4d156a9c6a899987d00b62a55eab380281 /activerecord/lib | |
parent | 4b1188b5abc66a42980e7708f78a54177b31c300 (diff) | |
download | rails-744552f72d49c222d6cc42ab8bad9a16a812377a.tar.gz rails-744552f72d49c222d6cc42ab8bad9a16a812377a.tar.bz2 rails-744552f72d49c222d6cc42ab8bad9a16a812377a.zip |
Fix extract default with CURRENT_TIMESTUMP
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index d435d91102..3e84786be0 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -495,12 +495,16 @@ module ActiveRecord end # Returns an array of +Column+ objects for the table specified by +table_name+. - def columns(table_name)#:nodoc: + def columns(table_name) # :nodoc: sql = "SHOW FULL FIELDS FROM #{quote_table_name(table_name)}" execute_and_free(sql, 'SCHEMA') do |result| each_hash(result).map do |field| type_metadata = fetch_type_metadata(field[:Type], field[:Extra]) - new_column(field[:Field], field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation]) + if type_metadata.type == :datetime && field[:Default] == "CURRENT_TIMESTAMP" + new_column(field[:Field], nil, type_metadata, field[:Null] == "YES", field[:Default], field[:Collation]) + else + new_column(field[:Field], field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation]) + end end end end |