mardi 21 avril 2015

Datamapper equivalent of SQL Query

I have a Trees Class in my rails application. In there I have a field called 'leaves'. Now for a certain operation, I need to execute the following SQL command with a bitwise & operation under condition.

SELECT * FROM trees WHERE (leaves & 6) = 6

How do I do it using datamapper ? I do not want to do it in the below way :

repository(:default).adapter.select('SELECT * FROM trees WHERE (leaves & 6) = 6')

Aucun commentaire:

Enregistrer un commentaire