aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-16 17:18:50 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-16 17:18:50 -0700
commit0d12a1f9ee8b19393ae2dd95d8c4007e84a63ca9 (patch)
treeef4d145ac60fb9ccdd9a73a78739a37861684f5e /src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
parent036eb2a9ed67822e18330f0b8c23e0fe702257fe (diff)
downloadbun-0d12a1f9ee8b19393ae2dd95d8c4007e84a63ca9.tar.gz
bun-0d12a1f9ee8b19393ae2dd95d8c4007e84a63ca9.tar.zst
bun-0d12a1f9ee8b19393ae2dd95d8c4007e84a63ca9.zip
reset on stmt on error
Diffstat (limited to 'src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp')
-rw-r--r--src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp b/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
index 2540e1dc0..d7cccd771 100644
--- a/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
+++ b/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
@@ -254,7 +254,7 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, JSC::JSValue
int index = sqlite3_bind_parameter_index(stmt, WTF::String(propertyName.string()).utf8().data());
if (index == 0) {
- throwException(globalObject, scope, createError(globalObject, "Unknown parameter name " + propertyName.string()));
+ throwException(globalObject, scope, createError(globalObject, "Unknown parameter \"" + propertyName.string() + "\""_s));
return JSValue();
}
@@ -646,7 +646,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementIsInTransactionFunction, (JSC::JSGlobalOb
return JSValue::encode(JSC::jsUndefined());
}
- RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(sqlite3_get_autocommit(db))));
+ RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(!sqlite3_get_autocommit(db))));
}
JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
@@ -1086,6 +1086,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob
if (UNLIKELY(status != SQLITE_DONE)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
@@ -1098,6 +1099,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob
RELEASE_AND_RETURN(scope, JSValue::encode(JSC::constructEmptyArray(lexicalGlobalObject, nullptr, 0)));
} else {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
}
@@ -1145,6 +1147,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob
RELEASE_AND_RETURN(scope, JSValue::encode(JSC::jsNull()));
} else {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
}
@@ -1164,6 +1167,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo
int statusCode = sqlite3_reset(stmt);
if (UNLIKELY(statusCode != SQLITE_OK)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(statusCode))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
@@ -1204,6 +1208,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo
if (UNLIKELY(status != SQLITE_DONE)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
@@ -1217,6 +1222,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo
RELEASE_AND_RETURN(scope, JSValue::encode(JSC::constructEmptyArray(lexicalGlobalObject, nullptr, 0)));
} else {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
+ sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
}
}
@@ -1254,6 +1260,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob
// sqlite3_reset(stmt);
RELEASE_AND_RETURN(scope, JSC::JSValue::encode(jsUndefined()));
} else {
+ sqlite3_reset(stmt);
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
return JSValue::encode(jsUndefined());
}