Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pg] Fix deeply nested queries failing due to table name length #3041

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from

Conversation

opl-
Copy link

@opl- opl- commented Oct 3, 2024

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 replacement hashString 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.

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.
@opl- opl- changed the title Fix deeply nested queries failing due to table name length [Pg] Fix deeply nested queries failing due to table name length Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant