Skip to content

Commit

Permalink
src: use env strings to create sqlite results
Browse files Browse the repository at this point in the history
PR-URL: nodejs#55785
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
targos authored Nov 17, 2024
1 parent e577618 commit b648d37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.") \
Expand Down Expand Up @@ -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") \
Expand Down
11 changes: 5 additions & 6 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,6 @@ void StatementSync::Run(const FunctionCallbackInfo<Value>& args) {
}

Local<Object> result = Object::New(env->isolate());
Local<String> last_insert_rowid_string =
FIXED_ONE_BYTE_STRING(env->isolate(), "lastInsertRowid");
Local<String> 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());
Expand All @@ -713,9 +709,12 @@ void StatementSync::Run(const FunctionCallbackInfo<Value>& 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;
}

Expand Down

0 comments on commit b648d37

Please sign in to comment.