Skip to content

Conversation

@himself65
Copy link

@himself65 himself65 commented Aug 25, 2025

What does this PR do?

Related: nodejs/node@d1eabcb
Related: nodejs/node#59405
Related: better-auth/better-auth#3869

Nowadays, there are tons of database packages, like sqlite3, sqlite, better-sqlite, bun:sqlite... Checking the difference from them is pretty hard.
instanceof is not good, since the developer will still need to import the module, which is costly.
I think we should provide a symbol to distinguish different SQLite classes, at least nodejs could make the first step

This symbol could help with lots of duplicate properties checking, like https://github.com/kysely-org/kysely, https://github.com/knex/knex

It helps the library author to write an adapter for a different SQLite library. Right now, the library is checking the prototype method to determine whether it's node:sqlite, bun:sqlite, or better-sqlite... It was a lot of performance, and it's not stable as the API could change

https://github.com/better-auth/better-auth/blob/375e9f3ced6f3842c133f4cae689cb2a604ba94a/packages/better-auth/src/adapters/kysely-adapter/dialect.ts#L53-L109

I hope there's an easy way. like a symbol tag, to determine the user's land SQLite lib

How did you verify your code works?

Adding tests

@alii
Copy link
Member

alii commented Aug 25, 2025

This seems reasonable - could you please add a comment in the code explaining why it's there? Would be good to link back to this GitHub issue, too.

@himself65
Copy link
Author

This seems reasonable - could you please add a comment in the code explaining why it's there? Would be good to link back to this GitHub issue, too.

There is no specefic issue to link, but I added the comment

@alii
Copy link
Member

alii commented Aug 25, 2025

Sorry, you're right. I meant this pull request as a link. It's useful because it points to the other implementations/discussions on other repos.

@alii
Copy link
Member

alii commented Aug 25, 2025

Thanks - I've unblocked CI ⏰

bartlomieju added a commit to denoland/deno that referenced this pull request Sep 8, 2025
Related:
nodejs/node@d1eabcb
Related: nodejs/node#59405
Related: better-auth/better-auth#3869
Related: oven-sh/bun#22109

Nowadays, there are tons of database packages, like sqlite3, sqlite,
better-sqlite, bun:sqlite... Checking the difference from them is pretty
hard.
instanceof is not good, since the developer will still need to import
the module, which is costly.
I think we should provide a symbol to distinguish different SQLite
classes, at least nodejs could make the first step.

---------

Signed-off-by: Alex Yang <[email protected]>
Co-authored-by: Bartek Iwańczuk <[email protected]>
Tango992 pushed a commit to Tango992/deno that referenced this pull request Sep 24, 2025
Related:
nodejs/node@d1eabcb
Related: nodejs/node#59405
Related: better-auth/better-auth#3869
Related: oven-sh/bun#22109

Nowadays, there are tons of database packages, like sqlite3, sqlite,
better-sqlite, bun:sqlite... Checking the difference from them is pretty
hard.
instanceof is not good, since the developer will still need to import
the module, which is costly.
I think we should provide a symbol to distinguish different SQLite
classes, at least nodejs could make the first step.

---------

Signed-off-by: Alex Yang <[email protected]>
Co-authored-by: Bartek Iwańczuk <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants