[1.7.x] Fixed #22648 -- Transform.output_type should respect overridden custom_lookup and custom_transform.

Previously, class lookups from the output_type would be used, but any
changes to custom_lookup or custom_transform would be ignored.

Backport of a2dd618 from master
[1.7.x] Fix a2dd618 for mysql.

Backport of 3b76502 from master