[8673] (preload query strategy for eager :includes) introduces an issue with pre-quoted table names.
String conditions work correctly
>> Person.find(:all, :conditions => ["accounts.domain = ?", 'example.com'], :include => :account)
=> []
However, if you properly quote table names in the conditions string, it raises an error.
>> Person.find(:all, :conditions => ["`accounts`.`domain` = ?", 'example.com'], :include => :account)
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'accounts.domain' in 'where clause': SELECT * FROM `people` WHERE (`accounts`.`domain` = 'example.com')
This is because the regular expression to determine if included tables are in the conditions doesn't take quoted names into account. Therefore, it drops the include option and fails.
This becomes more of an issue in queries where you need to use string conditions (LIKE, >, etc.)
Big thanks to Steve Smith for diagnosing the problem. I'm just the patch monkey.