[英]Rails migration: is it ok to use 'nil' as the default value for a boolean field?
Is there anything wrong with defaulting a boolean field to nil
rather than false
with an ActiveRecord migration for use with Postgres? 使用Postgres进行ActiveRecord迁移,将布尔字段默认为
nil
而不是false
是否有任何问题?
I like how it gives a small bit of extra data- whether or not that field has been marked as true or false yet. 我喜欢它如何提供一小部分额外数据 - 无论该字段是否已被标记为真或假。
没有什么可以阻止你在布尔上使用nil - 但是我个人喜欢我的布尔是真的还是假的,我发现nil会导致一些丑陋的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.