Issue #571548: Prevent Views generating SQL aliases which are too-long or duplicates
Closes #571548
Use safe SQL aliases.
We limit the length of the original alias (to a default maximum of 60 characters), incorporating a hash of the original value for uniqueness if that value was too long to use verbatim.
This prevents subsequent truncation from creating duplicate aliases in cases where two or more aliases are identical up to the point of truncation. This happens particularly easily with relationships, where alias names may be built from several concatenated identifiers.
Edited by jweowu