From 771db64cbe8ce24d9068812c3e00e7a4612e5c04 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:35:32 -0800 Subject: [bun:sqlite] cleanup `run` --- src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/bun.js/bindings/sqlite/JSSQLStatement.cpp') diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 39f1f42ed..d19009e01 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -1461,14 +1461,17 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob initializeColumnNames(lexicalGlobalObject, castedThis); } - if (status == SQLITE_ROW || status == SQLITE_DONE) { - // sqlite3_reset(stmt); - RELEASE_AND_RETURN(scope, JSC::JSValue::encode(jsUndefined())); - } else { + while (status == SQLITE_ROW) { + status = sqlite3_step(stmt); + } + + if (UNLIKELY(status != SQLITE_DONE)) { sqlite3_reset(stmt); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status)))); return JSValue::encode(jsUndefined()); } + + RELEASE_AND_RETURN(scope, JSC::JSValue::encode(jsUndefined())); } JSC_DEFINE_HOST_FUNCTION(jsSQLStatementToStringFunction, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -- cgit v1.2.3