简体   繁体   中英

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?

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会导致一些丑陋的代码

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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