aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/time_precision_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-04-14 09:49:39 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-04-14 14:22:16 +0900
commit28ec8c4a57197a43e4369bfbdfa92625bd592fe0 (patch)
tree5376680dc357962506b982cc9b4f6f82d2d263ab /activerecord/test/cases/time_precision_test.rb
parent128923ca14eeae032c2ed72b043e2bbcda09ab9c (diff)
downloadrails-28ec8c4a57197a43e4369bfbdfa92625bd592fe0.tar.gz
rails-28ec8c4a57197a43e4369bfbdfa92625bd592fe0.tar.bz2
rails-28ec8c4a57197a43e4369bfbdfa92625bd592fe0.zip
Add `quoted_time` for truncating the date part of a time column value
Context #24522. TIME column on MariaDB doesn't ignore the date part of the string when it coerces to time. ``` root@localhost [test] > CREATE TABLE `foos` (`id` int AUTO_INCREMENT PRIMARY KEY, `start` time(0), `finish` time(4)) ENGINE=InnoDB; Query OK, 0 rows affected (0.02 sec) root@localhost [test] > INSERT INTO `foos` (`start`, `finish`) VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); Query OK, 1 row affected, 2 warnings (0.00 sec) Note (Code 1265): Data truncated for column 'start' at row 1 Note (Code 1265): Data truncated for column 'finish' at row 1 root@localhost [test] > SELECT `foos`.* FROM `foos`; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '2000-01-01 12:30:00' LIMIT 1; Empty set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '12:30:00' LIMIT 1; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) ```
Diffstat (limited to 'activerecord/test/cases/time_precision_test.rb')
-rw-r--r--activerecord/test/cases/time_precision_test.rb1
1 files changed, 0 insertions, 1 deletions
diff --git a/activerecord/test/cases/time_precision_test.rb b/activerecord/test/cases/time_precision_test.rb
index c422daa859..628a8eb771 100644
--- a/activerecord/test/cases/time_precision_test.rb
+++ b/activerecord/test/cases/time_precision_test.rb
@@ -44,7 +44,6 @@ class TimePrecisionTest < ActiveRecord::TestCase
end
def test_formatting_time_according_to_precision
- skip("TIME column on MariaDB doesn't ignore the date part of the string when it coerces to time") if current_adapter?(:Mysql2Adapter) && ActiveRecord::Base.connection.mariadb?
@connection.create_table(:foos, force: true) do |t|
t.time :start, precision: 0
t.time :finish, precision: 4