charlypoly / attr_bitwise

Bitwise attribute for ruby class and Rails model
MIT License
68 stars 9 forks source link

Querying `any` does not returns null values #14

Open giulioprovasi opened 6 years ago

giulioprovasi commented 6 years ago

How should I do the following (using #13 as an example too) :

return all users who can see at least english and french content

user 1 => NULL user 2 => en

I assume NULL means any cause : User.first.languages => [:en, :fr, :ca] but : User.with_any_languages(:fr) => []

I am using the same scope :

  scope :with_any_languages, lambda { |*types_sym|
    where(languages_value: bitwise_union(*types_sym, 'languages'))
  }

Is this intended or a bug ?

kmanzana commented 6 years ago

@giulioprovasi, are you sure User.first.languages returns [:en, :fr, :ca]? I'm pretty sure it returns [:en, :fr, :ca, :empty].