drizzle-team / drizzle-team/drizzle-orm
[BUG]: Connection strings that use unix sockets are not supported on Postgres
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.39.1
### What version of `drizzle-kit` are you using?
0.30.4
### Other packages
_No response_
### Describe the Bug
I'm currently trying to connect to a database with the connection string as follows: `postgresql:///testdb`. This works with `psql`. However, when I pass it as the url for the drizzle-kit and drizzle-orm, it fails to connect as it is treating it as a TCP connection.
This type of connection string is valid as mentioned [here](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS).
Specifying the type of connection explicitly through the options provided works. So as a workaround, I'm currently doing something like this:
```js
// drizzle.config.js
const dbCredentials = process.env.DATABASE_URL?.trim().length
? {
url: process.env.DATABASE_URL
}
: {
host: '/run/postgresql',
port: 5432,
user: 'test_service',
database: 'testdb'
};
export default defineConfig({ /* other params */ dbCredentials });
```
```js
// ORM
const queryClient = env.DATABASE_URL?.trim().length
? postgres(env.DATABASE_URL)
: postgres({
host: '/run/postgresql',
port: 5432,
username: 'test_service',
db: 'testdb'
});
```
I'm using `"postgres": "^3.4.5"`. Kindly let me know if I need to file this issue in the postgres repo if this is not the right place. It would also be nice if this is documented for the time being, until support is added.
Contributor guide
Assessment
This issue has not been assessed yet.