puppetlabs/puppetdb — pull request #364 by cprice-puppet (2012-11-29 19:50:24+00:00)
Title: Fix bug relating to ambiguous "name" column for the "in" operator

This work is intended to fix the test failure that we have right
now for fact subqueries that use the `in` operator and try to
join on the `name` field. The problem is that "name" was ambiguous;
it could have been referring to either `certname_facts.name`, or
to `certnames.name` (which we were `JOIN`ing in to the query).

We decided that using a subselect in our `WHERE` clause (instead of
that `JOIN`) was cleaner, since the only reason we were `JOIN`ing
in the `certnames` table was to check the `deactivated` field (i.e.,
we weren't actually selecting any fields from that table). This
commit switches the logic for checking the `active` status to use
that approach.

As a side effect, it turned out that our entire infrastructure for
supporting `JOIN` clauses as a generic part of the query compilation
was no longer being used by any of the other code, so I discussed
with Nick and we decided to go ahead and remove it for now.