Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
sqlite: format code
  • Loading branch information
araujogui committed Sep 18, 2025
commit 3662e7187f22182404b01f210eb06715eca7eabf
28 changes: 12 additions & 16 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -689,17 +689,17 @@ int AuthorizerFunction::xAuthorizer(void* user_data,
// Convert SQLite authorizer parameters to JavaScript values
js_argv.emplace_back(Integer::New(isolate, action_code));
js_argv.emplace_back(
NullableSQLiteStringToValue(isolate, param1).ToLocalChecked());
NullableSQLiteStringToValue(isolate, param1).ToLocalChecked());
js_argv.emplace_back(
NullableSQLiteStringToValue(isolate, param2).ToLocalChecked());
NullableSQLiteStringToValue(isolate, param2).ToLocalChecked());
js_argv.emplace_back(
NullableSQLiteStringToValue(isolate, param3).ToLocalChecked());
NullableSQLiteStringToValue(isolate, param3).ToLocalChecked());
js_argv.emplace_back(
NullableSQLiteStringToValue(isolate, param4).ToLocalChecked());
NullableSQLiteStringToValue(isolate, param4).ToLocalChecked());

TryCatch try_catch(isolate);
MaybeLocal<Value> retval = fn->Call(
context, Undefined(isolate), js_argv.size(), js_argv.data());
MaybeLocal<Value> retval =
fn->Call(context, Undefined(isolate), js_argv.size(), js_argv.data());

if (try_catch.HasCaught()) {
// If there's an exception in the callback, deny the operation
Expand Down Expand Up @@ -1926,25 +1926,23 @@ void DatabaseSync::SetAuthorizer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();

if ( args[0]->IsNull() ) {
if (args[0]->IsNull()) {
// Clear the authorizer
sqlite3_set_authorizer(db->connection_, nullptr, nullptr);
return;
}

if (!args[0]->IsFunction()) {
THROW_ERR_INVALID_ARG_TYPE(
isolate,
"The \"callback\" argument must be a function or null.");
isolate, "The \"callback\" argument must be a function or null.");
return;
}

Local<Function> fn = args[0].As<Function>();
AuthorizerFunction* user_data = new AuthorizerFunction(env, fn, db);

int r = sqlite3_set_authorizer(db->connection_,
AuthorizerFunction::xAuthorizer,
user_data);
int r = sqlite3_set_authorizer(
db->connection_, AuthorizerFunction::xAuthorizer, user_data);

if (r != SQLITE_OK) {
delete user_data;
Expand Down Expand Up @@ -3264,10 +3262,8 @@ static void Initialize(Local<Object> target,
DatabaseSync::EnableLoadExtension);
SetProtoMethod(
isolate, db_tmpl, "loadExtension", DatabaseSync::LoadExtension);
SetProtoMethod(isolate,
db_tmpl,
"setAuthorizer",
DatabaseSync::SetAuthorizer);
SetProtoMethod(
isolate, db_tmpl, "setAuthorizer", DatabaseSync::SetAuthorizer);
SetSideEffectFreeGetter(isolate,
db_tmpl,
FIXED_ONE_BYTE_STRING(isolate, "isOpen"),
Expand Down
Loading