fix(drizzle): respect join.type config (#13258)

Respects join.type instead of hardcoding leftJoin
This commit is contained in:
Alessio Gravili
2025-07-25 15:46:20 -07:00
committed by GitHub
parent 6d6c9ebc56
commit 8518141a5e
3 changed files with 6 additions and 6 deletions

View File

@@ -29,8 +29,8 @@ export const countDistinct: CountDistinct = async function countDistinct(
.limit(1)
.$dynamic()
joins.forEach(({ condition, table }) => {
query = query.leftJoin(table, condition)
joins.forEach(({ type, condition, table }) => {
query = query[type ?? 'leftJoin'](table, condition)
})
// When we have any joins, we need to count each individual ID only once.

View File

@@ -30,8 +30,8 @@ export const countDistinct: CountDistinct = async function countDistinct(
.limit(1)
.$dynamic()
joins.forEach(({ condition, table }) => {
query = query.leftJoin(table as PgTableWithColumns<any>, condition)
joins.forEach(({ type, condition, table }) => {
query = query[type ?? 'leftJoin'](table as PgTableWithColumns<any>, condition)
})
// When we have any joins, we need to count each individual ID only once.

View File

@@ -56,8 +56,8 @@ export const selectDistinct = ({
query = query.where(where)
}
joins.forEach(({ condition, table }) => {
query = query.leftJoin(table, condition)
joins.forEach(({ type, condition, table }) => {
query = query[type ?? 'leftJoin'](table, condition)
})
return queryModifier({