activerecord-hackery / meta_search

Object-based searching (and more) for simply creating search forms. Not currently maintained.
http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/
MIT License
903 stars 140 forks source link

DEFAULT_WHERES `like` on non-string types #109

Open nicolai86 opened 12 years ago

nicolai86 commented 12 years ago

Hey,

I just tried making contain work on non-string types.

Patching MetaSearch::DEFAULT_WHERES enabled me to write the following:

Order.search(id_like: 12)

However, executing the query leads to SQL like the following:

SELECT * FROM orders where id like 0.

Some investigation turned out that MetaSearch correctly passes "%12%" to AREL, which seems to be the reason for my problem.

Do you have any idea on how to fix this, @ernie ? I'd like AREL not to change my "%12%" to 0.

Suggestions are welcome.

Thank you for your hard work!