MySQL-specific table and column name quoting in AREL visitor #18

Closed
wants to merge 16 commits into
from

Conversation

Projects
None yet
2 participants

visit_Arel_Nodes_Grouping uses backticks when checking for quoted table and column names. PostgreSQL uses double-quotes, and other DBs may use other weird characters, which will cause record-cache to claim that such queries are not cacheable. I changed visit_Arel_Nodes_Grouping to delegate table and column-name quoting to the ActiveRecord connection's quoting methods.

Also while I was at it, I made the check for ASC or DESC in handle_order_by case insensitive. For most purposes this shouldn't be necessary, but we had some weird associations with hand-written order by clauses.

Owner

orslumen commented Jun 11, 2014

Thank you for your contribution!

I used your ideas to improve the visit_Arel_Nodes_Grouping method. Note that I now match on a single non-word character instead of asking the connection to quote the table and column names. This is faster and works better in case different tables are stored in different DB's.

ASC and DESC are now parsed case insensitive.

I have not included your code with the callbacks and the option to invalidate all cached records, as that would add an extra cache lookup to each fetch call. I think that is too expensive.

@orslumen orslumen closed this Jun 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment