Select fields with the same name in two different tables in a join

Is it possible to select two fields of the same name, but from a different table, as part of a join? e.g.
db
.select({
inboxCurrencyCode: inboxes.currencyCode,
cardCurrencyCode: cards.currencyCode,
})
.from(transactions)
.leftJoin(inboxes, eq(transactions.inboxId, inboxes.id))
.leftJoin(cards, eq(transactions.cardId, cards.id))
db
.select({
inboxCurrencyCode: inboxes.currencyCode,
cardCurrencyCode: cards.currencyCode,
})
.from(transactions)
.leftJoin(inboxes, eq(transactions.inboxId, inboxes.id))
.leftJoin(cards, eq(transactions.cardId, cards.id))
As-is, it only ever gives me one of two currencyCode fields, even if they are technically renamed by the partial select
1 Reply
xeon06
xeon06OP13mo ago
GitHub
[BUG]: Broken shifted columns with leftJoin and same column name (o...
What version of drizzle-orm are you using? 0.25.4 What version of drizzle-kit are you using? 0.17.6 Describe the Bug I got broken results with leftJoin with same columns. Details My schema (partial...

Did you find this page helpful?