Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 567 Bytes

File metadata and controls

11 lines (8 loc) · 567 Bytes

Boolean columns without a NOT NULL constraint can hold three states: true, false, and NULL. This is rarely intentional and can lead to unexpected behavior in your application logic, since NULL is neither true nor false.

ThreeStateBooleanChecker finds boolean columns that are missing a NOT NULL constraint in the database.

To fix the issue, add a NOT NULL constraint and set a default value for the column:

# In a migration:
change_column_null :table_name, :column_name, false
change_column_default :table_name, :column_name, false