drizzle-team / drizzle-team/drizzle-orm
[BUG]: postgres-js transactions fail with invalid syntax if an empty config is provided
- 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.29.3
### What version of `drizzle-kit` are you using?
_No response_
### Describe the Bug
- Create a drizzle client using postgres-js
- call `drizzleClient.transaction(() => {}, {})`
- The client issues the query `'set transaction ;'` which causes a postgres error
### Expected behavior
An empty config should be treated as though no config is provided. Providing an empty config type-checks since all elements of the config object are marked as optional.
I'm pretty sure this problem arises due to a missing empty object check in https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/postgres-js/session.ts#L141 and https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/aws-data-api/pg/session.ts#L183 . These generate a `set transaction` command with zero options to configure.
Another option is to include the transaction options in the `begin` statement like most of the other postgres drivers do.
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.