drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

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

Open opl- opened this issue 1 year ago • 14 comments

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.

opl- avatar Oct 03 '24 01:10 opl-

@opl- thanks for your PR! We can merge it, could you please resolve all the conflicts first?

AndriiSherman avatar Nov 03 '24 14:11 AndriiSherman

Man it would be so nice if this got merged 🙏🙏.

smrdotgg avatar Nov 12 '24 23:11 smrdotgg

Begging the maintainers to free me from the endless merge conflict resolution hell. (Accidentally rebased onto main instead of beta.)

opl- avatar Dec 07 '24 02:12 opl-

I am dying to see this implemented, pretty please!

AirZona avatar Dec 09 '24 15:12 AirZona

@AndriiSherman can this be merged? It is marked as ready-to-be-merged and there are no conflicts anymore. Seems like it's just been forgotten for a few months...

alvesvaren avatar Feb 02 '25 12:02 alvesvaren

Please @AndriiSherman , desperately want this merged

AirZona avatar Feb 12 '25 22:02 AirZona

@AndriiSherman, in the future. What can we do to get your attention? Because this is taking a while.

QastanFIT avatar Feb 13 '25 05:02 QastanFIT

Please merge this, this issue is soooooo important to get merged in.

AirZona avatar Feb 25 '25 16:02 AirZona

Looks like this has been approved - will this be merged shortly? I am about to spin up a fork but if this will be merged I'll probably wait - this is a pretty big fix that would reduce a lot of headaches in my codebase

shreddish avatar Mar 01 '25 17:03 shreddish

Hey can you please merge and rollout this. I and many of us are urgently in need of this

hardikbhalodia99 avatar Mar 03 '25 10:03 hardikbhalodia99

This issue has hit me so many times. I cannot wait for this to be merged. PLEASE!

AirZona avatar Mar 24 '25 01:03 AirZona

@AndriiSherman I had to resolve merge conflicts three times by now. Since maintainers of this repository are allowed to push to my branch, next time I'll be leaving that task up to you.

opl- avatar Mar 26 '25 13:03 opl-

Hi! What's holding this up?

swoop2 avatar Apr 22 '25 09:04 swoop2

Really looking forward for this one too!

RobSchilderr avatar Apr 22 '25 10:04 RobSchilderr

Any update on this?

AirZona avatar Jul 02 '25 16:07 AirZona

Thanks for working on fixing this issue. Do we have a date for this pull request to be merged ?

656d696c65 avatar Jul 14 '25 09:07 656d696c65

Any updates on this one?

guilherssousa avatar Jul 28 '25 16:07 guilherssousa

Been forever since I wanted a PR merged more than this one.

AirZona avatar Jul 29 '25 15:07 AirZona

What's preventing this PR from getting merged?

RaduG avatar Jul 31 '25 18:07 RaduG

@AndriiSherman can we expect this to be merged before the next release?

akashkashyap avatar Aug 06 '25 16:08 akashkashyap