© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago
Jérémie

Mapped column name and relation with the original name

Hi, I am taking over an old project and have found an issue, I'm not sure if I should file it as a bug:
I have two MySql tables here is the oversimplified version:
events
- id
- artist

artists
- id
events
- id
- artist

artists
- id


In my drizzle schema I have mapped the events table this way:
export const events = mysqlTable(
    'events ',
    {
        id: int('id').autoincrement().primaryKey(),
        artistId: int('artist').notNull()
    },
    (agenda) => ({
        eventsArtistFk: foreignKey({ columns: [events.artistId], foreignColumns: [artists.id] })
    })
);
export const eventsRelations = relations(events , ({ one }) => ({
    artist: one(artists, {
        fields: [events.artistId],
        references: [artists.id]
    })
}));
export const events = mysqlTable(
    'events ',
    {
        id: int('id').autoincrement().primaryKey(),
        artistId: int('artist').notNull()
    },
    (agenda) => ({
        eventsArtistFk: foreignKey({ columns: [events.artistId], foreignColumns: [artists.id] })
    })
);
export const eventsRelations = relations(events , ({ one }) => ({
    artist: one(artists, {
        fields: [events.artistId],
        references: [artists.id]
    })
}));


This results in an error when I query the table using
{with: { artist: true}
{with: { artist: true}
It throws
Duplicate column name 'artist'
Duplicate column name 'artist'

If I simply use a different name for the relation everything works as expected.
I just wanted to know wether this is expected or if I should post it as an issue.

Thanks for reading
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Dynamic column name and insert
Drizzle TeamDTDrizzle Team / help
2y ago
relation columns name
Drizzle TeamDTDrizzle Team / help
16mo ago
Column name alias
Drizzle TeamDTDrizzle Team / help
3y ago
upsert with excluded using column name
Drizzle TeamDTDrizzle Team / help
2y ago