mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
moved sqlite patch into seperate file
This commit is contained in:
parent
e2790538a8
commit
a691b4ed35
19
spec/resources/sqlite_patch.rb
Normal file
19
spec/resources/sqlite_patch.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# patches adapter in rails 2.0 which mistakenly made time attributes map to datetime column type
|
||||
ActiveRecord::ConnectionAdapters::SQLiteAdapter.class_eval do
|
||||
def native_database_types #:nodoc:
|
||||
{
|
||||
:primary_key => default_primary_key_type,
|
||||
:string => { :name => "varchar", :limit => 255 },
|
||||
:text => { :name => "text" },
|
||||
:integer => { :name => "integer" },
|
||||
:float => { :name => "float" },
|
||||
:decimal => { :name => "decimal" },
|
||||
:datetime => { :name => "datetime" },
|
||||
:timestamp => { :name => "datetime" },
|
||||
:time => { :name => "time" },
|
||||
:date => { :name => "date" },
|
||||
:binary => { :name => "blob" },
|
||||
:boolean => { :name => "boolean" }
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -45,31 +45,10 @@ if RAILS_VER >= '2.1'
|
||||
ActiveRecord::Base.time_zone_aware_attributes = true
|
||||
end
|
||||
|
||||
|
||||
ActiveRecord::Migration.verbose = false
|
||||
ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'})
|
||||
|
||||
# patches adapter in rails 2.0 which mistakenly made time attributes map to datetime column typs
|
||||
if RAILS_VER < '2.1'
|
||||
ActiveRecord::ConnectionAdapters::SQLiteAdapter.class_eval do
|
||||
def native_database_types #:nodoc:
|
||||
{
|
||||
:primary_key => default_primary_key_type,
|
||||
:string => { :name => "varchar", :limit => 255 },
|
||||
:text => { :name => "text" },
|
||||
:integer => { :name => "integer" },
|
||||
:float => { :name => "float" },
|
||||
:decimal => { :name => "decimal" },
|
||||
:datetime => { :name => "datetime" },
|
||||
:timestamp => { :name => "datetime" },
|
||||
:time => { :name => "time" },
|
||||
:date => { :name => "date" },
|
||||
:binary => { :name => "blob" },
|
||||
:boolean => { :name => "boolean" }
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
require 'sqlite_patch' if RAILS_VER < '2.1'
|
||||
|
||||
require 'schema'
|
||||
require 'person'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user