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} It throws 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
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server