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

fix(db-postgres): long array field table aliases cause error even when dbName is used #11995

Merged
merged 2 commits into from
Apr 7, 2025

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Apr 4, 2025

Fixes #11975

Previously, this configuration was causing errors in postgres due to long names, even though dbName is used:

{
  slug: 'aliases',
  fields: [
    {
      name: 'thisIsALongFieldNameThatWillCauseAPostgresErrorEvenThoughWeSetAShorterDBName',
      dbName: 'shortname',
      type: 'array',
      fields: [
        {
          name: 'nested_field_1',
          type: 'array',
          dbName: 'short_nested_1',
          fields: [],
        },
        {
          name: 'nested_field_2',
          type: 'text',
        },
      ],
    },
  ],
},

This is because we were generating Drizzle relation name (for arrays) always based on the field path and internally, drizzle uses this name for aliasing. Now, if dbName is present, we use _{dbName} instead for the relation name.

@r1tsuu r1tsuu enabled auto-merge (squash) April 4, 2025 17:13
@r1tsuu r1tsuu merged commit 09782be into main Apr 7, 2025
74 checks passed
@r1tsuu r1tsuu deleted the fix/alias branch April 7, 2025 20:12
Copy link
Contributor

🚀 This is included in version v3.34.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long table aliases cause a postgres error even when a short dbName is used
2 participants