Skip to content

Commit

Permalink
0 precision is not the same as no precision
Browse files Browse the repository at this point in the history
And we are passing them as separate types in the query, which means 0
precision is still not supported by older versions of MySQL. I also
missed a handful of other cases where they need to be conditionally
applied.
  • Loading branch information
sgrif committed Sep 23, 2015
1 parent f696494 commit 2c7d0d4
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions activerecord/test/schema/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,17 @@ def except(adapter_names_to_exclude)
t.column :color, :string
t.column :parrot_sti_class, :string
t.column :killer_id, :integer
t.column :created_at, :datetime, precision: 0
t.column :created_on, :datetime, precision: 0
t.column :updated_at, :datetime, precision: 0
t.column :updated_on, :datetime, precision: 0
if subsecond_precision_supported?
t.column :created_at, :datetime, precision: 0
t.column :created_on, :datetime, precision: 0
t.column :updated_at, :datetime, precision: 0
t.column :updated_on, :datetime, precision: 0
else
t.column :created_at, :datetime
t.column :created_on, :datetime
t.column :updated_at, :datetime
t.column :updated_on, :datetime
end
end

create_table :parrots_pirates, id: false, force: true do |t|
Expand Down Expand Up @@ -582,15 +589,24 @@ def except(adapter_names_to_exclude)
create_table :pets, primary_key: :pet_id, force: true do |t|
t.string :name
t.integer :owner_id, :integer
t.timestamps null: false, precision: 6
if subsecond_precision_supported?
t.timestamps null: false, precision: 6
else
t.timestamps null: false
end
end

create_table :pirates, force: true do |t|
t.column :catchphrase, :string
t.column :parrot_id, :integer
t.integer :non_validated_parrot_id
t.column :created_on, :datetime, precision: 6
t.column :updated_on, :datetime, precision: 6
if subsecond_precision_supported?
t.column :created_on, :datetime, precision: 6
t.column :updated_on, :datetime, precision: 6
else
t.column :created_on, :datetime
t.column :updated_on, :datetime
end
end

create_table :posts, force: true do |t|
Expand Down Expand Up @@ -700,7 +716,11 @@ def except(adapter_names_to_exclude)
create_table :ship_parts, force: true do |t|
t.string :name
t.integer :ship_id
t.datetime :updated_at, precision: 6
if subsecond_precision_supported?
t.datetime :updated_at, precision: 6
else
t.datetime :updated_at
end
end

create_table :prisoners, force: true do |t|
Expand Down

0 comments on commit 2c7d0d4

Please sign in to comment.