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

feat: export database instances #132

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sandros94
Copy link

@sandros94 sandros94 commented Dec 11, 2024

Resolves #131

A non-breaking change that adds getInstance (following the naming convention from unstorage) to access a fully typed database client used internally.

Notes

  • planetscale not tested yet

@sandros94
Copy link
Author

while debugging why the mysql test is failing it was pointed out on discord that it is missing from the connector's meta

db0/src/index.ts

Lines 17 to 29 in 41ff740

export const connectors = {
sqlite: "db0/connectors/better-sqlite3",
postgresql: "db0/connectors/postgresql",
pglite: "db0/connectors/pglite",
"cloudflare-d1": "db0/connectors/cloudflare-d1",
libsql: "db0/connectors/libsql/node",
"libsql-node": "db0/connectors/libsql/node",
"libsql-http": "db0/connectors/libsql/http",
"libsql-web": "db0/connectors/libsql/web",
bun: "db0/connectors/bun-sqlite",
"bun-sqlite": "db0/connectors/bun-sqlite",
planetscale: "db0/connectors/planetscale",
} as const;

This at least explains the ts error

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@db54a4c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/connectors/bun-sqlite.ts 0.00% 2 Missing ⚠️
src/connectors/cloudflare-d1.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #132   +/-   ##
=======================================
  Coverage        ?   46.24%           
=======================================
  Files           ?       19           
  Lines           ?      679           
  Branches        ?       66           
=======================================
  Hits            ?      314           
  Misses          ?      360           
  Partials        ?        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahocevar
Copy link

Is there anything I can do to help finish this? Do we need to make Codecov happy? Are tests for mysql and planetscale needed?

@sandros94
Copy link
Author

Is there anything I can do to help finish this? Do we need to make Codecov happy? Are tests for mysql and planetscale needed?

Well yes.
While I don't have any idea what Codecov is reporting (links don't work for me, might just be a permission issue), it would be nice to have tests succeed. I still don't understand what makes mysql fail, while I haven't yet created a planetscale account

@ahocevar
Copy link

@sandros94 The tests you mentioned do not fail, they are just skipped. Also, the GitHub Actions checks pass, and there the same tests are skipped. Both in main and in your branch.

To clarify: did you mean to extend the test setup so these are not skipped?

@sandros94
Copy link
Author

@sandros94 The tests you mentioned do not fail, they are just skipped. Also, the GitHub Actions checks pass, and there the same tests are skipped. Both in main and in your branch.

To clarify: did you mean to extend the test setup so these are not skipped?

Oh sorry my bad.
Yeah I just skipped planetscale because I don't have an account yet. While for mysql I did setup a docker image and set the related test env vars, but failed in my branch (working in main)

@ahocevar
Copy link

Ok, I'll look into that. Thanks for the clarification.

@ahocevar
Copy link

@sandros94 The mysql2 tests pass for me also with your branch. I also don't have a PlanetScale account, so I cannot test that either.

@sandros94
Copy link
Author

sandros94 commented Jan 21, 2025

EDIT: I just realized what I was doing wrong. Now mysql2 passes also for me. Also, I don't see how this could be an issue for planetscale tbh.

@ahocevar thanks for helping, so mysql2 is probably a configuration issue on my end (I suspected that since I was having issues elsewhere too)

@ahocevar
Copy link

@sandros94 So the one thing I'm going to do is add tests for getInstance() to make codecov happy.

@ahocevar
Copy link

@sandros94 Done: sandros94#1

@sandros94
Copy link
Author

@pi0, sorry for the ping, but I just realized that when you will be able to review these PRs it might be useful to first merge #136, so that I might integrate those changes here.
I could theoretically type something like Connector<TInstance = keyof DriverMeta> based on those generated types. WDYT, am I overengineering things as usual? 😅

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.

allow returning the client
2 participants