[Pg] Fix deeply nested queries failing due to table name length #3041
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Postgres has a 63 character limit on table and table alias names. Defining a relation with a long name, or using a query which retrieves multiple levels of relations, could generate a relation table alias name which exceeds this limit.
This PR fixes that by trimming off the beginning of the relation table alias names if they exceed this 63 character limit. The beginning was chosen, as I believe the end is more likely to contain information useful for identifying the relation in a query.
Node's
crypto
and the Crypto Web API are not available for use due to the available libraries configured in TypeScript. The replacementhashString
function uses a completely made up hashing algorithm - it does not need to be secure. It just needs to generate unique outputs. I tested it to ensure it generates different outputs given similar strings.Compared to #2991, this PR does not use Node's
crypto
package, and attempts to preserve the relation names instead of hashing the entire alias.Fixes #2066. Closes #2991.