Rails 中使用 mysql 的 tinyint 字段类型需要注意一些事情,有陷阱,请小心。
- 默认 Rails 把
tinyint(1)
作为 boolean 类型的映射,所以我们不能使用tinyint(1)
- 在 Migration 的create_table 中,我们不能使用 t.tinyint 定义 tinyint 字段,只能使用
t.column :name :tinyint
Rails 中使用 mysql 的 tinyint 字段类型需要注意一些事情,有陷阱,请小心。
tinyint(1)
作为 boolean 类型的映射,所以我们不能使用 tinyint(1)
t.column :name :tinyint
一 | 二 | 三 | 四 | 五 | 六 | 日 |
---|---|---|---|---|---|---|
« 二 | ||||||
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |