Massively refactor and sanify condition collapsing
Wow... what a ride. This commit adds a faithful reimplementation of the
SQLA descend algorithm, but instead of SQL produces a reduced HASH that
nevertheless corresponds to the original query 1:1 (or so I *really* hope)
This is another one of these "I can try it with DQ but I don't even have
tests" stories, so once again opted to implement things the "dumb" way.
The benefits are quite substantial:
- Better deduplication of WHERE condition
- Consolidated functions - the vaguely similar logic in the current version
of _collapse_cond replaces almost the entirety of:
::DBIHacks::_extract_fixed_condition_columns
::ResultSet::_collapse_cond
::ResultSet::_stack_cond
- Extra fixes for create/populate inheritance corner cases
- More predictable SQL condition generation order (which incidentally may
prove problematic down the road with broken tests, but oh well, we'll
burn when we get there)
- Ton of extra tests and corner cases
We even managed to fulfill a longstanding TODO, even though it is a *lucky*
side-effect and not a real fix. Making a note to address this later... sigh.
This work started from
d8b7d9f58..337f3ee80, which while taking the right
direction had too many loose ends. ilmari++