Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/perry-api-manifest/src/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ pub static API_MANIFEST: &[ApiEntry] = &[
// Manifest-consistency catch-up (release-sweep gate): NATIVE_MODULE_TABLE
// had a `raw` row that wasn't mirrored here.
method("better-sqlite3", "raw", true, None),
// #1022 — surface the rest of the v8-proxy-materialized methods so
// the api-docs drift check stays green. `pragma` / `iterate` /
// `pluck` / `columns` / `transaction` are wired through
// `perry-jsruntime::bridge::materialize_sqlite_*_proxy` for the V8
// fallback path (drizzle on better-sqlite3); the native-side
// codegen lowering already routes the same names through
// `NATIVE_MODULE_TABLE`.
method("better-sqlite3", "pragma", true, None),
method("better-sqlite3", "iterate", true, None),
method("better-sqlite3", "pluck", true, None),
method("better-sqlite3", "columns", true, None),
method("better-sqlite3", "transaction", true, None),
// tursodb (#424). open / exec / execBatch / close /
// lastInsertRowid / isAutocommit shipped in v0.5.543; queryAll /
// queryOne shipped in v0.5.553 (close the row-as-object gap by
Expand Down
32 changes: 32 additions & 0 deletions crates/perry-ext-better-sqlite3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,38 @@ pub extern "C" fn js_sqlite_in_transaction(db_handle: Handle) -> i32 {
0
}

/// Returns `1` if `handle` currently resolves to a `SqliteDbHandle` in
/// this crate's perry-ffi handle registry, `0` otherwise. Used by the
/// V8 bridge in `perry-jsruntime::bridge::native_object_to_v8` to
/// decide whether to materialize a `v8::Object` proxy with `prepare` /
/// `exec` / `pragma` / `close` / `transaction` method callbacks when a
/// sqlite Database crosses the native→V8 boundary (drizzle's
/// `BetterSQLiteSession` does `this.client.prepare(query.sql)` from
/// session.js — refs #1022).
#[no_mangle]
pub extern "C" fn js_sqlite_is_db_handle(handle: Handle) -> i32 {
if get_handle::<SqliteDbHandle>(handle).is_some() {
1
} else {
0
}
}

/// Returns `1` if `handle` currently resolves to a `SqliteStmtHandle`
/// in this crate's perry-ffi handle registry, `0` otherwise. Mirror
/// of `js_sqlite_is_db_handle` for the Statement side of the V8 proxy
/// materialization — drizzle's PreparedQuery calls `stmt.run(...)` /
/// `stmt.all(...)` / `stmt.get(...)` / `stmt.raw().all(...)` on the
/// handle returned from `client.prepare(...)`. Refs #1022.
#[no_mangle]
pub extern "C" fn js_sqlite_is_stmt_handle(handle: Handle) -> i32 {
if get_handle::<SqliteStmtHandle>(handle).is_some() {
1
} else {
0
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading
Loading