简体   繁体   English

Rails迁移:使用'nil'作为布尔字段的默认值是否可以?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM