drizzle-team / drizzle-team/drizzle-orm
[BUG]: select with optional left join gives IsDrizzleTable type
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
0.28.6
### What version of `drizzle-kit` are you using?
0.19.3
### Describe the Bug
Code
```typescript
async findAll(input: z.infer) {
const { _, $inferSelect, $inferInsert, ...columns } = suppliers;
const query = this.db
.select({
...columns,
...(input.withCount && {
productsCount: sql`count(${products.id})`
.mapWith(Number)
.as('products_count'),
}),
})
.from(suppliers);
if (input.haveProducts || input.withCount) {
query.leftJoin(products, eq(suppliers, products.supplierId));
}
if (input.haveProducts) {
query.having(sql`products_count >= 1`);
}
const result = await query.execute();
return result;
}
```
this code giving me this error
```typescript
typescript: Return type of public method from exported class has or is using name 'IsDrizzleTable' from external module "C:/Users/hitech/code/autosync_nest/node_modules/.pnpm/drizzle-orm@0.28.6_@types+pg@8.10.7_pg@8.11.3/node_modules/drizzle-orm/table" but cannot be named. [4053]
```
or is this better way to do optional join and having in query?
### Expected behavior
_No response_
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.