From b648d37ad76072f380d167baf84863507975f0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 17 Nov 2024 10:25:03 +0100 Subject: [PATCH] src: use env strings to create sqlite results PR-URL: https://github.com/nodejs/node/pull/55785 Reviewed-By: Richard Lau Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- src/env_properties.h | 2 ++ src/node_sqlite.cc | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/env_properties.h b/src/env_properties.h index 4265b87c516..429c51a1f94 100644 --- a/src/env_properties.h +++ b/src/env_properties.h @@ -90,6 +90,7 @@ V(cached_data_string, "cachedData") \ V(cache_key_string, "cacheKey") \ V(change_string, "change") \ + V(changes_string, "changes") \ V(channel_string, "channel") \ V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \ V(clone_unsupported_type_str, "Cannot clone object of unsupported type.") \ @@ -215,6 +216,7 @@ V(jwk_y_string, "y") \ V(kill_signal_string, "killSignal") \ V(kind_string, "kind") \ + V(last_insert_rowid_string, "lastInsertRowid") \ V(length_string, "length") \ V(library_string, "library") \ V(line_number_string, "lineNumber") \ diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 3e08ed796e9..a791b724124 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -694,10 +694,6 @@ void StatementSync::Run(const FunctionCallbackInfo& args) { } Local result = Object::New(env->isolate()); - Local last_insert_rowid_string = - FIXED_ONE_BYTE_STRING(env->isolate(), "lastInsertRowid"); - Local changes_string = - FIXED_ONE_BYTE_STRING(env->isolate(), "changes"); sqlite3_int64 last_insert_rowid = sqlite3_last_insert_rowid(stmt->db_->Connection()); sqlite3_int64 changes = sqlite3_changes64(stmt->db_->Connection()); @@ -713,9 +709,12 @@ void StatementSync::Run(const FunctionCallbackInfo& args) { } if (result - ->Set(env->context(), last_insert_rowid_string, last_insert_rowid_val) + ->Set(env->context(), + env->last_insert_rowid_string(), + last_insert_rowid_val) .IsNothing() || - result->Set(env->context(), changes_string, changes_val).IsNothing()) { + result->Set(env->context(), env->changes_string(), changes_val) + .IsNothing()) { return; }