ManageIQ/rails — pull request #1 by lfu (2013-11-04 21:29:10+00:00)
Title: Fix an issue with where clause with a dot character.

A SQL query with a condition value containing dot character causes join query based eager loading.

[Bug 1018392][1]

Rails 3 has 2 approaches to avoid the N+1 queries problem. One involves creating a big join based query to pull in your associations, the other involves making a separate query per association.

When you call includes, rails decides which strategy to use. The default is to use the separate query approach unless it thinks you are referencing the columns from the associations in you conditions or order. Since that only works with the joins approach, it uses that instead.

Due to a bug in rails method tables_in_string, a SQL query that contains dot characters in the condition uses the join based query approach when the separate query approach is intended.

The test cases in this commit are written to verify that the SQL query works as intended, specially with rails future release.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1018392