aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-04-14 21:45:41 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-04-15 03:45:02 +0900
commit73af7945d534f866b2a11624be36d905fdc92b51 (patch)
tree9b02bdbd9259b86b35685a4ac2f6d1cf77071b20 /activerecord/test
parent4769fc4b4d5af7a8e93cc497d744151086aa5034 (diff)
downloadrails-73af7945d534f866b2a11624be36d905fdc92b51.tar.gz
rails-73af7945d534f866b2a11624be36d905fdc92b51.tar.bz2
rails-73af7945d534f866b2a11624be36d905fdc92b51.zip
Should keep quoting behaivor of a time column value in sqlite3 adapter
Follow up to #24542. In MySQL and PostgreSQL, a time column value is saved as ignored the date part of it. But in SQLite3, a time column value is saved as a string. We should keep previous quoting behavior in sqlite3 adapter. ``` sqlite> CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "start" time(0), "finish" time(4)); sqlite> INSERT INTO "foos" ("start", "finish") VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); sqlite> SELECT "foos".* FROM "foos"; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '2000-01-01 12:30:00' LIMIT 1; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '12:30:00' LIMIT 1; sqlite> ```
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/sqlite3/quoting_test.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb
index 87a892db37..f3ec2b98d3 100644
--- a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb
+++ b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb
@@ -8,9 +8,7 @@ module ActiveRecord
class SQLite3Adapter
class QuotingTest < ActiveRecord::SQLite3TestCase
def setup
- @conn = Base.sqlite3_connection :database => ':memory:',
- :adapter => 'sqlite3',
- :timeout => 100
+ @conn = ActiveRecord::Base.connection
end
def test_type_cast_binary_encoding_without_logger
@@ -89,6 +87,13 @@ module ActiveRecord
assert_equal "'hello'", @conn.quote(type.serialize(value))
end
+
+ def test_quoted_time_returns_date_qualified_time
+ value = ::Time.utc(2000, 1, 1, 12, 30, 0, 999999)
+ type = Type::Time.new
+
+ assert_equal "'2000-01-01 12:30:00.999999'", @conn.quote(type.serialize(value))
+ end
end
end
end