ernie/squeel — Issue #76: Is there a squeel equivalent of passing LENGTH(str) method call to db?
Author: konung
Created: 2011-11-13 21:21:45+00:00
State: open

Hello.

Just wondering how would you write this statement in squeel short of passing actual SQL bits and pieceses. In MySQL you can do something like this:

SELECT * FROM customers WHERE LENGTH(manufacturer_code ) > 6

This is example is kind of specific to a client we are creating an app for - 6 char codes mean a US based dealer, 7 - char codes are Canadian dealers. We are trying to normalize and clean up table. Just wondering if there is a way to write something like that statement in pure ruby, whithout using sql like I do right now. It's not a big deal just wondering...

Customer.where("LENGTH(manufacturer_code) > 6")