FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

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

Fresh3 months ago
Mar 14, 20260 views
Confidence Score81%
81%

Problem

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

Error Output

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 ge

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: [BUG]: Deeply nested queries fail due to table name length

Low Risk

I'm experiencing a similar issue, where the query says the column does not exist due name truncating

77

Trust Score

5 verifications

100% success
  1. 1

    I'm experiencing a similar issue, where the query says the column does not exist

    I'm experiencing a similar issue, where the query says the column does not exist due name truncating

Validation

Resolved in drizzle-team/drizzle-orm GitHub issue #2066. Community reactions: 11 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugrqbprioritybug/fixed-in-beta