puppetlabs/puppetdb — pull request #1194 by wkalt (2014-12-27 00:02:14+00:00)
Title: (maint) Allow factset ordering on hash

This corrects an oversight in adding the hash field to factsets that left
ordering results on hash impossible. I'm not a fan of the solution here, but it
follows our approach for environments and I can't think of a better way ATM.
The constraints are:

a) The factsets query must be "doubled up" in jdbc.clj so that paging options are applied
on an object basis instead of a by-row basis (a factset comprises multiple rows.)

b) Both environment and hash are nullable fields in factsets, so a COALESCE is
necessary to prevent a "WHERE null IN null" scenario.