sql - Ruby datamapper - search in flag value -


i have user table (datamapper model) has column called permission contains bitmask value.

property :permission, flag[:perm1, :perm2, :perm3]

i want find users have permissions, such perm1 , perm2

so call,

user.all(:permission => [:perm1, :perm2])

this makes query

select * user permission = 3 incorrect. while correct query should have been (because type - flag)

select * user permission &1 != 0 , permission &2 != 0

does in ruby datamapper, how make call search in flag values.

i not find direct way it. did use hack.

user.all(:conditions => ['permission & ? != 0 , permission & ? != 0', 1,2])


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -