more useful options | |
PerlMonks |
DBIx::Class : match integer-cols having specific bits setby bliako (Monsignor) |
on Sep 28, 2020 at 18:26 UTC ( [id://11122300]=perlquestion: print w/replies, xml ) | Need Help?? |
bliako has asked for the wisdom of the Perl Monks concerning the following question: Enlightened Brothers, I am having bit (!) trouble with telling DBIx::Class to match records where a specific column of integer type (actually BIGINT) has specific bit(s) set. The equivalent SQL is something like: select * from TABLE where (roles & 4) = 1 (Edit: the RHS of this where expression, i.e.: =1 was written rather hastily and it does not make sense for checking if the 2nd LSbit is set. roles=4 is much clearer and probably faster. Instead, (roles&4) = 4, (roles&4) > 0. (roles&4)=0 make more sense in my particular scenario) Since we are on the topic, I have not yet understood how to use the column-name in a search with DBIx::Class. For example how to DBIx::Class this: select * from TABLE where (roles & 4) = (roles & 2) ? I can also settle for someone telling me how to pass a custom WHERE-in-SQL using DBIx::Class::ResultSet::search(), if possible. Oh! MySQL latest bw, bliako
Back to
Seekers of Perl Wisdom
|
|