Add support for resource/fact subqueries
Implement resource/resource subqueries
Add a failing test that v1 subqueries are unsupported
(#17397) DB pool setup fails with numeric username/pw

Our config file parsing code tries to be clever and automatically
convert things that look like numbers into proper numbers. That's never
been a problem. However, interop with Java requires specific types
(nothing is auto-coerced or converted).

This bug happens during `make-connection-pool`. If the username or
password is numeric, when parsing the configuration file they're turned
into numbers. Then when we interop with BoneCP, we get an error because
we're passing in numbers when strings are expected.

As these are the only 2 possible properties that may be auto-converted
to numbers, simply coercing them to the correct type is sufficient.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Refactor query implementation

This reduces duplication by creating a com.puppetlabs.puppetdb.query
namespace, which now holds the actual query operators. The operators are
now explicitly listed per-endpoint, rather than using a multimethod.
This allows us to separate v1 from v2 query, so that we can maintain
backward compatibility by not supporting subqueries for resources in the
v1 API. It also means we only have a single implementation of 'and',
'or', and 'not', as well as the general query framework.

Query is now driven by the query/resource-query->sql and
query/fact-query->sql functions, which accept as an argument the map of
operators to function implementations to use.

This commit also changes the subquery API itself a bit. The column to
correlate with for 'in-result' and 'project' no longer needs to be
namespaced, and 'node' is no longer supported in place of 'certname'
(for consistency).
Update spec about new subqueries
Merge branch 'master' into resource-subqueries
Merge branch 'master' into resource-subqueries
Fix JDBC connection pool test on Postgres

When using Postgres as the test database, there's no guarantee the user this
test is trying to connect as exists. If it doesn't, the test hangs, trying
perpetually to connect. Given that the only thing we care about is that we can
build the appropriate connection pool, there's no need to actually connect. So
now we just build the object and go on, so this will work on both test
databases.
Add documentation for the query compiler

Also added some better error handling and pre/post-conditions.
Enact bracket conservation efforts
Merge pull request #344 from nicklewis/resource-subqueries

Add support for resource subqueries
Don't namespace query terms when it's not necessary

The only terms we namespace now are ["fact" <fact name>], ["parameter"
<parameter name>] and ["node" "active"]. The first two are many-to-one
queries, so this makes sense. The last term is mostly just weird not to
namespace, so we'll leave it that way for now.
Rename the "fact" column of certname_facts to "name"

This makes some things much easier and more consistent. For instance, we
use "name" on the resource_params table already. And this way we don't
have to do weird mapping between "name" in our API and "fact" in the
database.
Don't use namespaced query terms in terminuses
Merge pull request #345 from nicklewis/namespaced-fields

De-namespace query terms, and rename "fact" to "name"
Merge remote-tracking branch 'origin/master' into feature/master/report-storage

Conflicts:
	src/com/puppetlabs/puppetdb/query/resource.clj
	src/com/puppetlabs/puppetdb/scf/migrate.clj