drizzle-team / drizzle-team/drizzle-orm
[BUG]: "Cannot read properties of undefined" because empty "rows" data was not excluded
- 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.36.0
### What version of `drizzle-kit` are you using?
0.27.1
### Describe the Bug
I use Drizzle SQLite Proxy to connect and execute queries to a SQLite WASM database. Return type of "RemoteCallback" function is `Promise<{ rows: any[] }>`. It means that "rows" data can be an empty array.
In `drizzle-orm/src/sqlite-proxy/session.ts` file, an empty array is passed through `mapGetResult` function. It leads to a few bugs in where not check `undefined`. So I think we need to escape empty array.
```typescript
if (!row || row.length === 0) {
return undefined;
}
// ...
return mapResultRow(
this.fields!,
row,
this.joinsNotNullableMap,
);
```
### Expected behavior
_No response_
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.