RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
770 stars 69 forks source link

` DATABASE_URL` should alias `pg://` to `postgres://` #67

Closed loynoir closed 6 months ago

loynoir commented 1 year ago

Actual

$ DATABASE_URL="pg://xxx" npm exec kysely-codegen
• Loaded environment variables from .env file.
• No dialect specified. Assuming 'sqlite'.
node:internal/modules/cjs/loader:1075
  const err = new Error(message);
              ^

Error: Cannot find module 'better-sqlite3'
Require stack:

Expected

$ DATABASE_URL="postgres://xxx" npm exec kysely-codegen
• Loaded environment variables from .env file.
• No dialect specified. Assuming 'postgres'.
• Introspecting database...
✓ Introspected 10 tables and generated ./node_modules/kysely-codegen/dist/db.d.ts in 20ms.

Version

$ grep version node_modules/kysely-codegen/package.json
  "version": "0.10.0",

Upvote & Fund

Fund with Polar

akxcv commented 1 year ago

Also postgresql:// is a valid protocol for postgres, but is not recognised by kysely-codegen.

AdamZaczek commented 11 months ago

Bump. I'm excited about the premise of the tooling but inability to connect easily made me procrastinate on trying the tool further. The reasoning is - if this common scenario crashes, more problems are likely coming.

RobinBlomberg commented 6 months ago

I believe I have fixed this, I just missed closing this issue.

This file asserts that postgres://, postgresql:// and pg:// all work.

Also, I would like to remind everyone that this is an open source project I work on for free, and pull requests are warmly welcome. But this issue should be resolved. 👍