You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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)
asWHERE 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 }
andwhere: Sequel[:field] =~ true
,or you use
where(:field)
,where { field }
andwhere: 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?
The text was updated successfully, but these errors were encountered: