-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
sqlite,test,doc: accept Buffer and URL as paths #56991
sqlite,test,doc: accept Buffer and URL as paths #56991
Conversation
446d48b
to
18fe76b
Compare
2a608e1
to
5b5a8cf
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56991 +/- ##
==========================================
- Coverage 90.33% 90.25% -0.08%
==========================================
Files 630 630
Lines 184537 184681 +144
Branches 36077 36138 +61
==========================================
- Hits 166693 166686 -7
- Misses 10950 11021 +71
- Partials 6894 6974 +80
|
06d30bf
to
4561203
Compare
303de33
to
7019435
Compare
07a5b31
to
114df4d
Compare
I think this needs a rebase to fix the CI issue. cc: @nodejs/sqlite since this PR was opened before the team existed. |
@@ -256,6 +274,15 @@ suite('DatabaseSync.prototype.exec()', () => { | |||
}); | |||
}); | |||
|
|||
test('throws if the URL does not have the file: scheme', (t) => { |
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.
You should also check the happy path.
Can you try URL("file://path/to/db.db?mode=ro")
and verify that writes error out?
Passing a file://
or file:
as URL as a string or Buffer should also be supported.
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.
Done
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.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
test/parallel/test-sqlite-backup.mjs:53
- [nitpick] Consider clarifying the error message terminology: while a Buffer is used in tests, the message refers to Uint8Array. Explicitly mentioning Buffer (or clarifying that Buffer is acceptable since it is a Uint8Array) could reduce potential confusion.
message: 'The "destination" argument must be a string, Uint8Array, or URL without null bytes.'
test/parallel/test-sqlite-database-sync.js:31
- [nitpick] For consistency with tests using Buffer objects, consider updating the error message to explicitly mention Buffer, or note that Buffer instances are valid as they are a subtype of Uint8Array.
message: /The "path" argument must be a string, Uint8Array, or URL without null bytes/
You can ignore the review by Copilot. I was curious to see if it would generate anything helpful. There are actual failures on Windows in the CI though:
|
6d48eee
to
8508790
Compare
Thanks, Colin. I had forgotten to close the database connection 😅 |
if (file_url->type != ada::scheme::FILE) { | ||
THROW_ERR_INVALID_URL_SCHEME(env->isolate()); | ||
return std::nullopt; | ||
} |
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.
I removed the FileURLToPath
because it was stripping the query params out. We should keep them since SQLite supports them.
Guaranteeing that a valid URL is given we can return the URL href it is.
22e4331
to
e145acb
Compare
e145acb
to
7d1111f
Compare
Landed in c7cf677 |
PR-URL: #56991 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Closes #56940
This PR adds the capability to the sqlite module to accept Buffer and URL as the database location.