提交 57d534ee 编写于 作者: P Piotr Sarnacki

Merge pull request #6344 from erichmenge/patch_sqlite_time_type

SQLite3 doesn't actually support the 'time' type.
......@@ -191,7 +191,7 @@ def native_database_types #:nodoc:
:decimal => { :name => "decimal" },
:datetime => { :name => "datetime" },
:timestamp => { :name => "datetime" },
:time => { :name => "time" },
:time => { :name => "datetime" },
:date => { :name => "date" },
:binary => { :name => "blob" },
:boolean => { :name => "boolean" }
......
......@@ -35,6 +35,11 @@ def test_column_types
assert(!result.rows.first.include?("blob"), "should not store blobs")
end
def test_time_column
owner = Owner.create!(:eats_at => Time.utc(1995,1,1,6,0))
assert_match /1995-01-01/, owner.reload.eats_at.to_s
end
def test_exec_insert
column = @conn.columns('items').find { |col| col.name == 'number' }
vals = [[column, 10]]
......
......@@ -522,7 +522,7 @@ def test_default_values
end
# Oracle, and Sybase do not have a TIME datatype.
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
unless current_adapter?(:OracleAdapter, :SybaseAdapter, :SQLite3Adapter)
def test_utc_as_time_zone
Topic.default_timezone = :utc
attributes = { "bonus_time" => "5:42:00AM" }
......@@ -764,6 +764,9 @@ def test_multiparameter_attributes_on_time_with_raise_on_small_time_if_missing_d
end
def test_multiparameter_attributes_on_time_will_ignore_hour_if_missing
ActiveRecord::Base.time_zone_aware_attributes = false
ActiveRecord::Base.default_timezone = :local
Time.zone = nil
attributes = {
"written_on(1i)" => "2004", "written_on(2i)" => "12", "written_on(3i)" => "12",
"written_on(5i)" => "12", "written_on(6i)" => "02"
......@@ -870,7 +873,7 @@ def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_at
end
# Oracle, and Sybase do not have a TIME datatype.
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
unless current_adapter?(:OracleAdapter, :SybaseAdapter, :SQLite3Adapter)
def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion
ActiveRecord::Base.time_zone_aware_attributes = true
ActiveRecord::Base.default_timezone = :utc
......@@ -891,6 +894,9 @@ def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attr
end
def test_multiparameter_attributes_on_time_with_empty_seconds
ActiveRecord::Base.time_zone_aware_attributes = false
ActiveRecord::Base.default_timezone = :local
Time.zone = nil
attributes = {
"written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
"written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => ""
......@@ -946,7 +952,7 @@ def test_multiparameter_assignment_of_aggregation_with_large_index
def test_attributes_on_dummy_time
# Oracle, and Sybase do not have a TIME datatype.
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
return true if current_adapter?(:OracleAdapter, :SybaseAdapter, :SQLite3Adapter)
attributes = {
"bonus_time" => "5:42:00AM"
......
......@@ -431,6 +431,7 @@ def create_table(*args, &block)
t.string :name
t.column :updated_at, :datetime
t.column :happy_at, :datetime
t.column :eats_at, :time
t.string :essay_id
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册