make enums distinct per class
Merge pull request #14609 from evanwhalen/enums_inheritance

Make enums distinct per class
Ignore order when doing count.

This is necessary because Postgresql doesn't play nice with ORDER BY and
no GROUP BY.

Fixes #14621.
Merge pull request #14631 from laurocaetano/fix_count_with_order

Ignore order when doing count.
Use connection-specific bytea escaping

In our normal usage, it's rare for this to make a difference... but is
more technically correct.

As well as a spec that proves this is a good idea, let's also add a more
sane-looking one that just covers basic to_sql functionality. There
aren't many places where we actually use escape_bytea, but that's one
that won't be going away.
Merge pull request #14632 from matthewd/escape_bytea

Use connection-specific bytea escaping
Remove useless begin..end