Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11465 (closed enhancement: fixed)

Opened 5 months ago

Last modified 5 months ago

[PATCH] Support for TIME datatype in SQLite

Reported by: h-lame Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: tiny sqlite
Cc:

Description

sqlite.sql in activerecord/test/schema defines Topic.bonus_time to be of TIME datatype (and this dates back to r40!), however native_database_types in the sqlite_adapter translates :time columns into "datetime" columns in the DB.

In short this means that although the test/schema for sqlite creates a TIME column, you can never do this via activerecord directly. This also means that if we do the following:

rake test_sqlite
# wait for tests to complete
rake test_sqlite TEST=test/cases/base_test.rb

we get 2 fails in base_test that we didn't get when running the full test suite: test_utc_as_time_zone and test_attributes_on_dummy_time. These fail this time because the migration tests (run after base_test in the full test suite) rebuild the Topic table and this causes bonus_time to be created as a :datetime, not :time. This in turn changes how AR coerces values into bonus_time (ActiveRecord::ConnectionAdapters::Column.string_to_time instead of ActiveRecord::ConnecitonAdapters::Column.string_to_dummy_time) and thus, our tests fail.

Attachments

support_for_time_columns_in_sqlite.diff (0.7 kB) - added by h-lame on 03/29/08 18:57:03.
Tiny change to allow AR based creation of TIME columns in sqlite

Change History

03/29/08 18:57:03 changed by h-lame

  • attachment support_for_time_columns_in_sqlite.diff added.

Tiny change to allow AR based creation of TIME columns in sqlite

03/29/08 19:02:19 changed by h-lame

Um... I've only tested this in sqlite3 (not sqlite as it claims in the description). Although that's a typo I think that given how old the sqlite.sql is, it'll apply to sqlite as well.

04/04/08 11:45:13 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

(In [9222]) Tiny change to allow AR based creation of TIME columns in sqlite. Closes #11465 [h-lame]