-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi rubocop & sequel users and rubocop-sequel maintainers!
We've recently faced an issue with partial indexes using boolean field.
Basically, when index has condition WHERE field
and sequel generates (where(field: true)
as WHERE field IS TRUE
, index isn't used, by postgres regardless of the nullability of the field. The same is true vice-versa. This is the expected behavior, but we only faced it recently when we discovered that partial index can help us. Before, we didn't pay attention to which conditions we used and used them interchangeably (and it didn't create a problem because of not-nullable columns).
What I think would be great in rubocop-sequel is to enforce boolean conditions to one style:
either you use where(field: true)
, where { field =~ true }
and where: Sequel[:field] =~ true
,
or you use where(:field)
, where { field }
and where: Sequel[:field]
.
The former is preferred and should be default because of null handling, but one may have a different setup, so I guess having it configurable might make sense.
I think such cop may help with different kinds of related problems.
Do you think it make sense to have such cop?