Modify delete to not take any params#405
Open
ospfranco wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy optional location parameter from db.delete() across the TypeScript typings, Node implementation, native (C++) host function, and documentation, aligning deletion with the database’s own opened path rather than caller-provided paths.
Changes:
- Update TS types (
DB/_InternalDB) sodeleteis strictly zero-argument. - Update Node
NodeDatabase.delete()and Node tests to match the new signature. - Simplify native
deletehost function to remove the location-path override logic; add API docs forclose/delete.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Changes delete type to () => void for RN/web package types. |
| src/index.ts | Formatting/import style changes (no functional change intended). |
| src/index.web.ts | Formatting/import style changes (no functional change intended). |
| node/src/types.ts | Changes Node DB.delete type to () => void. |
| node/src/database.ts | Updates NodeDatabase.delete() to take no args and delete this.dbPath. |
| node/src/test.spec.ts | Updates cleanup code to call delete() with no args (plus formatting). |
| docs/docs/api.md | Adds/updates API docs for close and delete using the new signature. |
| cpp/DBHostObject.cpp | Removes location-argument handling from the native delete host function. |
Comments suppressed due to low confidence (1)
cpp/DBHostObject.cpp:287
- After opsqlite_*_remove() the underlying db handle is closed, but DBHostObject::delete() doesn’t clear
db(unlike close(), which sets db to nullptr/{}). If JS calls close() after delete() (or any other method that usesdb), this can double-close or use a stale handle. Consider mirroring close(): waitFinished(), remove, then set db to nullptr/{} (and/or route through invalidate()).
function_map["delete"] = HFN(this) {
invalidated = true;
#ifdef OP_SQLITE_USE_LIBSQL
opsqlite_libsql_remove(db, db_name, base_path);
#else
opsqlite_remove(db, db_name, base_path);
#endif
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
283
to
287
| #ifdef OP_SQLITE_USE_LIBSQL | ||
| opsqlite_libsql_remove(db, db_name, path); | ||
| opsqlite_libsql_remove(db, db_name, base_path); | ||
| #else | ||
| opsqlite_remove(db, db_name, path); | ||
| opsqlite_remove(db, db_name, base_path); | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was some legacy stuff there from the migrations to HostObjects. Overlaps with #404