0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Switches between standard SQL and extended SQL syntax depending on the adapter.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Runtime

= 2.8.1
= 0.10.1
= 3.0.3
= 2.4.0
 Project Readme

tune_my_query

About

tune_my_query is an extension of the gem me_gusta written by John Pignata

It is a simple way to switch between standard SQL and extended SQL syntax depending on the adapter. For example: PostgreSql has an ILIKE extension which is not found in other databases like mysql. This gem(not released yet) ensures the query is adapted based on the current database.

Inspiration

Gemcutter uses PostgreSql in production and uses ILIKE in one of the queries. For anyone, hacking on their local machine will have to change it to LIKE for it to work. Also, when it comes to accepting patches from a MySql user this would again pose a minor issue. Hence, this gem.

Usage

It is simple to use. Just install it like:

sudo gem install tune_my_query

And do the following in the model class where you have used a database specific SQL, like this:

tune_my_query :like

Here 'like' signifies the extension to usual SQL LIKE.

Does it only work with LIKE? What a futile effort

Yes, at the moment it only does that. But, you can fork the code and add your own commands in the lib/commands directory. Every new command you add should have a name ending with "Command". For example: AwesomeCommand. Add a singleton "execute" method to it and send me a patch, I will add it in. Please do add specs.

Specs

In order to run the specs you should have mysql and postgresql installed. Here's how to install PostgreSql on a Mac. And, just do:

sudo gem install pg

to install postgreSql adapter or you can use bundler and install project dependencies with it.

Bugs

Please report the issues through gitHub's issues.

Authors

Roadmap

  • To make it work for any database extension. At the moment it would only work for PostgreSql specific SQL extensions.