DT
Drizzle Team11mo ago
nk

Using "which" to check an alias isn't working.

// missing FROM-clause entry for table "notSubcategory"
search?.categoryId ? eq(notSubcategoryTable.categoryId, search.categoryId) : undefined,
// works fine
search?.subcategoryId
? eq(productTable.categoryId, search.subcategoryId)
: undefined,
// missing FROM-clause entry for table "notSubcategory"
search?.categoryId ? eq(notSubcategoryTable.categoryId, search.categoryId) : undefined,
// works fine
search?.subcategoryId
? eq(productTable.categoryId, search.subcategoryId)
: undefined,
...(select?.category
? {
subcategory: categoryTable,
category: notSubcategoryTable,
}
: {}),
...(select?.category
? {
subcategory: categoryTable,
category: notSubcategoryTable,
}
: {}),
if (select?.category) {
query.leftJoin(
categoryTable,
eq(productTable.categoryId, categoryTable.id)
);
query.leftJoin(
notSubcategoryTable,
eq(notSubcategoryTable.id, categoryTable.categoryId)
);

groupBy.push(notSubcategoryTable.id);
groupBy.push(categoryTable.id);
}
if (select?.category) {
query.leftJoin(
categoryTable,
eq(productTable.categoryId, categoryTable.id)
);
query.leftJoin(
notSubcategoryTable,
eq(notSubcategoryTable.id, categoryTable.categoryId)
);

groupBy.push(notSubcategoryTable.id);
groupBy.push(categoryTable.id);
}
Am I missing something?
3 Replies
nk
nkOP11mo ago
I just want to make my search work with both the subcategory and category I've been trying to get this simple thing to work for so long that I am fr going crazy Are you fr telling me the problem is that alias() wasn't working as a global That's crazy Omggg I'm so fking stupid I literally forgot that it was counting them and never joined it
nk
nkOP11mo ago
It took me like 6 hours to figure that out LOL
No description
nk
nkOP11mo ago
I was literally trying to fix one function and the error was in another one
Want results from more Discord servers?
Add your server