Skip to content

Commit

Permalink
SQLite3 doesn't actually support the 'time' type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erich Menge committed May 16, 2012
1 parent 7994496 commit d9fc180
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
12 changes: 9 additions & 3 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)" => ""
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions activerecord/test/schema/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d9fc180

Please sign in to comment.