Skip to content

Conversation

@akapug
Copy link
Member

@akapug akapug commented Nov 26, 2025

Ready for review Powered by Pull Request Badge

Summary

Updates Statement.run() and Database.exec() to return a Changes object instead of undefined, matching the Bun SQLite API.

Problem

Per the TypeScript types and Bun compatibility, run() and exec() should return a Changes object:

interface Changes {
  changes: number;        // rows affected
  lastInsertRowid: number | bigint;
}

Previously:

  • Statement.run() returned Unit (undefined in JS)
  • Database.exec() returned Undefined.instance

Solution

  1. New SQLiteChanges interface - Defines the contract matching Bun's Changes
  2. SQLiteChangesImpl - Internal implementation as a ProxyObject for JS interop
  3. Updated exec() - Now captures update count and last insert rowid from JDBC
  4. Updated run() - Returns the result from exec()

Changes

File Change
SQLiteChanges.kt New interface
SQLiteStatement.kt run() returns SQLiteChanges
SQLiteDatabase.kt exec() returns SQLiteChanges
SqliteModule.kt Implementation

Usage

const db = new Database(":memory:");
db.run("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");

const result = db.run("INSERT INTO users (name) VALUES (?)", ["Alice"]);
console.log(result.changes);        // 1
console.log(result.lastInsertRowid); // 1

Fixes

Fixes #1791

@akapug akapug requested a review from sgammon as a code owner November 26, 2025 03:26
…bject

Previously, run() returned undefined and exec() returned Undefined.instance.
Now both return a SQLiteChanges object with:
- changes: number of affected rows
- lastInsertRowid: rowid of the last inserted row

This matches the Bun SQLite API behavior.

Fixes elide-dev#1791
@akapug akapug force-pushed the fix/sqlite-run-returns-changes branch from 064997d to 8b529bd Compare November 26, 2025 05:28
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.

SQLite run() returns undefined instead of Changes object

1 participant