Skip to content

[BUG]: Deeply nested queries fail due to table name lengthΒ #2066

@EamonHeffernan

Description

@EamonHeffernan

What version of drizzle-orm are you using?

0.30.1

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

When creating a query with deeply nested data, the sql generated uses names based on the relation names that have been set up, with more text being appended to the name for each level of depth.
"table1"
"table1_table2"
"table1_table2_table3"
etc...

If this reaches the limit for the length of a table name, the database will truncate the names to the number of allowed characters, and fail with the error error: table name "documentVersions_workflowStep_workflow_contract_entities_userEn" specified more than once because there were multiple more tables in the name that are cut off. They instead all get truncated to the same string which causes an error.

Expected behavior

Drizzle should either use shorter names upon reaching the limit for a table name, or use aliases within the request that get turned back into the correct names upon response. This ideally should not be something the drizzle user has to worry about, as the query builder should preferably work without having to manually set table names for all the joins.

Environment & setup

This occurs using postgresql

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbug/fixed-in-betaThis bug has been fixed in beta (or will be soon).priorityWill be worked on nextrqbrelational queries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions