Skip to content

Commit f545129

Browse files
committed
Fix boolean columns triggering MySQL deprecation
Previously, when creating a boolean column for a MySQL database ```ruby class AddSoldToProduct < ActiveRecord::Migration[8.0] def change add_column :products, :sold, :boolean end end ``` Active Record would create a query like ```SQL ALTER TABLE `products` ADD `sold` tinyint(1) ``` which would trigger a deprecation warning in MySQL 8.0.17+ ``` 1681: Integer display width is deprecated and will be removed in a future release. ``` Additionally, starting in MySQL 8.0.19, integer display widths are no longer included in the output of `SHOW CREATE TABLES` with the exception of `tinyint(1)` because > MySQL Connectors make the assumption that TINYINT(1) columns > originated as BOOLEAN columns; this exception enables them to continue > to make that assumption. This commit changes Active Record to use the `boolean` alias for MySQL (which still results in `tinyint(1)` columns) but does not emit the deprecation warning for using an integer display width. ```SQL ALTER TABLE `products` ADD `sold` boolean ```
1 parent e592dc1 commit f545129

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AbstractMysqlAdapter < AbstractAdapter
4242
date: { name: "date" },
4343
binary: { name: "blob" },
4444
blob: { name: "blob" },
45-
boolean: { name: "tinyint", limit: 1 },
45+
boolean: { name: "boolean" },
4646
json: { name: "json" },
4747
}
4848

0 commit comments

Comments
 (0)