When we use associations within same tables, it fails due to
conflicted table names.
For example, eager loading in acts_as_tree generates following
query and DBMS raises an ambiguous column name error.
List.find(:all, :include=>"children")
=> "SELECT lists.id AS t0_r0, ..., lists.id AS t1_r0 ..."
This patch allows table sequencial aliases like autonumber.
For first appearance, the orignal table name is used, and then
suffix with "_t%d" will be appended.
List.find(:all, :include=>"children")
=> "SELECT lists.id AS t0_r0, ..., lists_t2.id AS t1_r0 ...
FROM lists LEFT OUTER JOIN lists AS lists_t2 ON ..."
All tests are passed on MySQL and SQLite3.
Best regards.