-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix(db): update db-client connection options parsing #13772
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
Conversation
🦋 Changeset detectedLatest commit: 637d863 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Luiz Ferraz <[email protected]>
|
Can we add some tests @Adammatthiesen ? |
Uhhh, how would I implement a test for this? 😅 Not exactly sure how I would setup that test... What this is being used for is setting up the libsql client to use an embedded replica of a remote server which creates a local (file or in memory) copy of the remote db that gets synced back and forth to the remote during runtime. |
We could export the function and they have a simple unit test that covers the basics. What worries me is that you haven't written anything under the testing section, so it's hard to understand what we're fixing and the fix works. |
Your talking about the parse options function correct? To be clear, the issue is the following, currently if you have the following ENV variable from the astro docs: ASTRO_DB_REMOTE_URL=file://local-copy.db?encryptionKey=your-encryption-key&syncInterval=60&syncUrl=libsql%3A%2F%2Fyour.server.ioit would be parsed as all strings for the config object, which would be invalid. Since the libSQLConfig object type wants the So current functionality would parse it as: {
url: "file://local-copy.db",
encryptionKey: "your-encryption-key",
syncInterval: "60",
syncUrl: "libsql://your.server.io",
}When it SHOULD be getting parsed as: {
url: "file://local-copy.db",
encryptionKey: "your-encryption-key",
syncInterval: 60, // <-- This is supposed to be a number according to the libSQL Config type
syncUrl: "libsql://your.server.io",
} |
|
As for the test, I suggest the following:
Let me know if you have more questions |
Will get to work on that here soon, sorry passed out after i sent that last message 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏
* update AstroDB client * Update packages/db/src/runtime/db-client.ts Co-authored-by: Luiz Ferraz <[email protected]> * add test * fix function to ensure only values that are passed are actually being passed --------- Co-authored-by: Luiz Ferraz <[email protected]>
Changes
pnpm exec changesetThis PR ensures proper params are being parsed and sent to the libsql Client, due to URLSearchParams being a
Record<string, string>this object requires parsing to ensure the values are being parsed to number or boolean.See https://discord.com/channels/830184174198718474/1370190284855705680 for context.
Testing
Added a new unit test for ensuring the URL parsing is correct in various circumstances.
Docs
This PR corrects internal logic to reflect the information on the docs. No docs changes needed.