Skip to content

Modify delete to not take any params#405

Open
ospfranco wants to merge 4 commits into
mainfrom
oscar/fix-delete
Open

Modify delete to not take any params#405
ospfranco wants to merge 4 commits into
mainfrom
oscar/fix-delete

Conversation

@ospfranco
Copy link
Copy Markdown
Contributor

@ospfranco ospfranco commented May 17, 2026

There was some legacy stuff there from the migrations to HostObjects. Overlaps with #404

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) so delete is strictly zero-argument.
  • Update Node NodeDatabase.delete() and Node tests to match the new signature.
  • Simplify native delete host function to remove the location-path override logic; add API docs for close/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 uses db), 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 thread cpp/DBHostObject.cpp
Comment thread cpp/DBHostObject.cpp Outdated
Comment thread cpp/DBHostObject.cpp
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
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