Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alternate dialects in the multiverse of sqlite #1292

Open
uncomplexity opened this issue Dec 13, 2024 · 5 comments
Open

alternate dialects in the multiverse of sqlite #1292

uncomplexity opened this issue Dec 13, 2024 · 5 comments

Comments

@uncomplexity
Copy link

I'm currently fine using the better-sqlite3 dialect, switching from postgresql to sqlite sped up my dx so fast.

Just crossed my mind though, since on postgresql it defaults to pg but there's an alternate one based on postgres which is also very cool.. on sqlite do you see any benefits on using the nodejs internal sqlite they're working on, and also on turso's limbo?

Links mentioned

@jlarmstrongiv
Copy link
Contributor

There are several dialects available at https://github.com/subframe7536/kysely-sqlite-tools

However, the Node.js dialect is not supported yet subframe7536/kysely-sqlite-tools#13

@arthurfiorette
Copy link

would be sick to have node's built in sqlite driver into kysely as a native dialect!

@subframe7536
Copy link

I think node:sqlite's api is similar to better-sqlite3, so maybe we can directly use SqliteDialect without any other efforts

@igalklebanov
Copy link
Member

igalklebanov commented Dec 21, 2024

It is not similar. Getting Error: Unknown named parameter '0' errors in tests.

better-sqlite3:

prepare(sql: string): {
  all(parameters: unknown[])
  reader: boolean
  run(parameters: unknown[])
}

node:sqlite:

prepare(sql: string): {
  all(namedParameters: Record<string, unknown>, ...anonymousParameters: unknown[])
  reader: boolean
  run(namedParameters: Record<string, unknown>, ...anonymousParameters: unknown[])
}

More incompatibilities with migrations.

@mmgoodnow
Copy link

mmgoodnow commented Dec 23, 2024

haven't played with any migrations yet, but I took a stab here. It relies on VERY new versions of node that aren't yet typed. https://github.com/mmgoodnow/kysely-node-sqlite/blob/df086d566e9e9cefb0b6d8edc253a8cd428c8d2b/dialect/sqlite-dialect.ts

The differences are pretty minimal -

  • StatementSync.reader doesn't seem to exist - I replaced with SelectQueryNode.is which I'm not sure is right generally, but seems right enough for my purposes 🤷
  • you have to spread the params array into arguments on StatementSync methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants