drizzle-team / drizzle-team/drizzle-orm

[BUG]: `getSQL` on subquery not working

Open
#2,174 4 comments 7 reactions 0 assignees View on GitHub
bug
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.30.1

### What version of `drizzle-kit` are you using?

_No response_

### Describe the Bug

The following code does not work:
```ts
const inner = db
.$with("inner")
.as(
db
.select()
.from(someTable)
);

const s = sql.empty();
s.append(inner.getSQL());
```

Currently when running this code I receive the following error:
`TypeError: inner.getSQL is not a function`

### Expected behavior

`getSQL` to be implemented to avoid the runtime error.

Given their is a type definition for it, it seems unintentional this method is missing at runtime.

### Environment & setup

_No response_

---

Thanks for all your work on Drizzle ORM. It's such a great tool!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.