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

fix(adapters): allow async SQLite clients #9355

Merged
merged 6 commits into from
Dec 10, 2023

Conversation

Schniz
Copy link
Contributor

@Schniz Schniz commented Dec 9, 2023

☕️ Reasoning

Drizzle supports the @libsql/client package, which is like better-sqlite3 but Promise based. Right now, the Drizzle adapter
only works with sync code, so it's not possible to use @libsql/client with it. This PR adds support for async code to the
Drizzle adapter, so that @libsql/client can be used with it (and therefore Turso can be used with it transitively).

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Please scout and link issues that might be solved by this PR.

Fixes #9276, Fixes #8335, Closes #8363 (this PR adds tests too)

📌 Resources

libsql is like sqlite, and supported by drizzle,
but it's a Promise-based API unlike standard SQLite which
is synchronous.
Copy link

vercel bot commented Dec 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2023 3:21am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
auth-docs-nextra ⬜️ Ignored (Inspect) Visit Preview Dec 10, 2023 3:21am
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Dec 10, 2023 3:21am

Copy link

vercel bot commented Dec 9, 2023

@Schniz is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added adapters Changes related to the core code concerning database adapters drizzle @auth/drizzle-adapter labels Dec 9, 2023
Copy link

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
drizzle-kit 0.19.12...0.20.6 None +4/-0 15.1 MB dankochetov

@balazsorban44 balazsorban44 changed the title fix: adapter-drizzle: fix adapter when using libsql fix(adapters): allow async SQLite clients Dec 10, 2023
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@balazsorban44 balazsorban44 merged commit 96903ed into nextauthjs:main Dec 10, 2023
9 of 10 checks passed
@MrCuriousGuy
Copy link

Thanks for the change! Any chance that index.ts gets edited in order to accept the libsql-client and not only drizzle's BaseSQLiteDatabase?

@Schniz
Copy link
Contributor Author

Schniz commented Dec 10, 2023

That should be a different adapter but it shouldn't be very hard to implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Changes related to the core code concerning database adapters drizzle @auth/drizzle-adapter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drizzle adapter with SQLite is not working with async clients Support Async SQLite Clients with DrizzleORM
3 participants