mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add mysql and sqlite3 default test
[Gannon McGibbon + Kenji Suzuki]
This commit is contained in:
parent
d8ac08f6bf
commit
15e04b4ef8
3 changed files with 23 additions and 3 deletions
|
@ -853,8 +853,7 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
assert_equal company, Company.find(company.id)
|
||||
end
|
||||
|
||||
# TODO: extend defaults tests to other databases!
|
||||
if current_adapter?(:PostgreSQLAdapter)
|
||||
if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter, :SQLite3Adapter)
|
||||
def test_default
|
||||
with_timezone_config default: :local do
|
||||
default = Default.new
|
||||
|
@ -866,7 +865,10 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
# char types
|
||||
assert_equal "Y", default.char1
|
||||
assert_equal "a varchar field", default.char2
|
||||
assert_equal "a text field", default.char3
|
||||
# Mysql text type can't have default value
|
||||
unless current_adapter?(:Mysql2Adapter)
|
||||
assert_equal "a text field", default.char3
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,13 @@ ActiveRecord::Schema.define do
|
|||
end
|
||||
end
|
||||
|
||||
create_table :defaults, force: true do |t|
|
||||
t.date :fixed_date, default: "2004-01-01"
|
||||
t.datetime :fixed_time, default: "2004-01-01 00:00:00"
|
||||
t.column :char1, "char(1)", default: "Y"
|
||||
t.string :char2, limit: 50, default: "a varchar field"
|
||||
end
|
||||
|
||||
create_table :binary_fields, force: true do |t|
|
||||
t.binary :var_binary, limit: 255
|
||||
t.binary :var_binary_large, limit: 4095
|
||||
|
|
11
activerecord/test/schema/sqlite_specific_schema.rb
Normal file
11
activerecord/test/schema/sqlite_specific_schema.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
ActiveRecord::Schema.define do
|
||||
create_table :defaults, force: true do |t|
|
||||
t.date :fixed_date, default: "2004-01-01"
|
||||
t.datetime :fixed_time, default: "2004-01-01 00:00:00"
|
||||
t.column :char1, "char(1)", default: "Y"
|
||||
t.string :char2, limit: 50, default: "a varchar field"
|
||||
t.text :char3, limit: 50, default: "a text field"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue