collectiveidea/awesome_nested_set — pull request #151 by Mik-die (2012-09-07 19:10:46+00:00)
Title: use tablename in all select queries

This patch adds table name in each 'SELECT' sql query. Previously this applies to some queries, that leads to errors in complex queries.

For example, if I make next complex query, using ActiveRecord:

```ruby
Campaign.joins(:category_associations => :category).merge(@category.self_and_descendants).uniq
```

this leads to SQL

```sql
SELECT DISTINCT "campaigns".* FROM "campaigns" INNER JOIN "category_associations" ON "category_associations"."campaign_id" = "campaigns"."id" INNER JOIN "categories" ON "categories"."id" = "category_associations"."category_id" WHERE ("categories"."lft" >= 1 AND "categories"."lft" < 16) ORDER BY "lft"
```

Pay attention on ```ORDER BY "lft"``` at the end. It leads to exception, because it's related to ```categories``` table, not ```campaigns```