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

[BUG]: Drizzle creating identifiers with name greater than 63 bytes without warning (critical) #4003

Open
1 task done
ssahillppatell opened this issue Jan 25, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ssahillppatell
Copy link

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0..38.4

What version of drizzle-kit are you using?

0.30.2

Other packages

No response

Describe the Bug

Undesired Behavior

As per this documentation the limit for the length of an identifier in Postgres is 63 bytes. Anything larger is truncated by default. This is causing unexpected bugs in the DB.

I have a table that references another table . And the autogenerated identifier is longer than 63 bytes. This was the created SQL:

ALTER TABLE "myschema"."roles_myproject_gpt_assistants" ADD CONSTRAINT "roles_myproject_gpt_assistants_assistant_id_myproject_gpt_assistants_id_fk" FOREIGN KEY ("assistant_id") REFERENCES "myschema"."myproject_gpt_assistants"("id") ON DELETE no action ON UPDATE no action;

This identifier is greater than 63 bytes and the rest of the identifier is truncated and is causing multiple identifiers to have the same name.

Steps to reproduce

  1. Create a sample db having two tables with long names and long column names.
  2. Create a foreign key relation between them.

Environment I am on

PostgreSQL: 16
Driver: [email protected]
Runtime: [email protected]

Expected Behavior

Drizzle shouldn't auto generated an identifier longer than 63 bytes without warning. Or add a random string (say asX4ft_) in front of the identifier by default if the name is not provided explicitly.

@ssahillppatell ssahillppatell added the bug Something isn't working label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant