diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-02-10 11:52:01 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-02-10 11:55:59 -0700 |
commit | f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7 (patch) | |
tree | 655c1e521e1bbe2a6c3cec8b8178bd7dc843c187 /activerecord/test/cases/adapters/mysql2/datetime_test.rb | |
parent | f926c1c953df6037654732c57a6c6b23db91c9fa (diff) | |
download | rails-f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7.tar.gz rails-f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7.tar.bz2 rails-f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7.zip |
Refactor microsecond precision to be database agnostic
The various databases don't actually need significantly different
handling for this behavior, and they can achieve it without knowing
about the type of the object.
The old implementation was returning a string, which will cause problems
such as breaking TZ aware attributes, and making it impossible for the
adapters to supply their logic for time objects.
Diffstat (limited to 'activerecord/test/cases/adapters/mysql2/datetime_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/datetime_test.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/datetime_test.rb b/activerecord/test/cases/adapters/mysql2/datetime_test.rb index ae00f4e131..7a37247d6a 100644 --- a/activerecord/test/cases/adapters/mysql2/datetime_test.rb +++ b/activerecord/test/cases/adapters/mysql2/datetime_test.rb @@ -4,15 +4,12 @@ if mysql_56? class DateTimeTest < ActiveRecord::TestCase self.use_transactional_fixtures = false - class Foo < ActiveRecord::Base; end - - def test_default_datetime_precision - ActiveRecord::Base.connection.create_table(:foos, force: true) - ActiveRecord::Base.connection.add_column :foos, :created_at, :datetime - ActiveRecord::Base.connection.add_column :foos, :updated_at, :datetime - assert_nil activerecord_column_option('foos', 'created_at', 'precision') + teardown do + ActiveRecord::Base.connection.drop_table(:foos, if_exists: true) end + class Foo < ActiveRecord::Base; end + def test_datetime_data_type_with_precision ActiveRecord::Base.connection.create_table(:foos, force: true) ActiveRecord::Base.connection.add_column :foos, :created_at, :datetime, precision: 1 |