1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #44535 from rnkaufman/respect-auto-increment-setting

Respect auto increment setting in abstract mysql adapter
This commit is contained in:
John Hawthorn 2022-02-23 14:36:34 -08:00 committed by GitHub
commit 53f703b3e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -722,7 +722,9 @@ module ActiveRecord
options[:comment] = column.comment
end
options[:auto_increment] = column.auto_increment?
unless options.key?(:auto_increment)
options[:auto_increment] = column.auto_increment?
end
td = create_table_definition(table_name)
cd = td.new_column_definition(column.name, type, **options)

View file

@ -1347,6 +1347,21 @@ if ActiveRecord::Base.connection.supports_bulk_alter?
assert_equal "This is a comment", column(:birthdate).comment
end
if current_adapter?(:Mysql2Adapter)
def test_updating_auto_increment
with_bulk_change_table do |t|
t.change :id, :bigint, auto_increment: true
end
assert column(:id).auto_increment?
with_bulk_change_table do |t|
t.change :id, :bigint, auto_increment: false
end
assert_not column(:id).auto_increment?
end
end
def test_changing_index
with_bulk_change_table do |t|
t.string :username