drizzle-team / drizzle-team/drizzle-orm

[BUG]: Select operation returning [] while using ORM but not while using SQL

Open
#2,671 3 comments 1 reaction 0 assignees View on GitHub
bug driver/libsql priority
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.32.0

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

0.23.0

### Describe the Bug

I am using Drizzle ORM with Turso SQLite.

I am trying to select the items in a table but I am getting [] (empty array) while using the ORM style fetching. Code and screenshot below
```ts
export async function test() {
const result = await db.select().from(fooTable).all()
return result
}
```
Output:

![image](https://github.com/user-attachments/assets/cd1ac9bd-1400-4451-9f1f-624182ab6763)

But while using SQL I am getting the correct output, code and screenshot below:
```ts
export async function test() {
const result = (await db.run(sql`SELECT * from ${fooTable}`)).rows
return result
}
```
Output:

![image](https://github.com/user-attachments/assets/11dfdb64-61e2-4291-96f9-72725d7a1bd7)

Surprisingly, Insert operation works with the ORM fetching, with this code
```ts
export async function test() {
const result = await db.insert(fooTable).values({ bar: "Deveesh Shetty" }).returning()
return result
}
```

### Expected behavior

This code should also return the rows in the table and not an empty array

```ts
export async function test() {
const result = await db.select().from(fooTable).all()
return result
}
```

### Environment & setup

Development environment
Using
Next.js `14.2.5`
Package Manager: pnpm `9.5.0`

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.