| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -434,6 +434,7 @@ | |||
| 434 | 434 | V(socketaddress_constructor_template, v8::FunctionTemplate) \ | |
| 435 | 435 | V(space_stats_template, v8::DictionaryTemplate) \ | |
| 436 | 436 | V(sqlite_column_template, v8::DictionaryTemplate) \ | |
| 437 | + V(sqlite_run_result_template, v8::DictionaryTemplate) \ | ||
| 437 | 438 | V(sqlite_statement_sync_constructor_template, v8::FunctionTemplate) \ | |
| 438 | 439 | V(sqlite_statement_sync_iterator_constructor_template, v8::FunctionTemplate) \ | |
| 439 | 440 | V(sqlite_session_constructor_template, v8::FunctionTemplate) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2406,7 +2406,7 @@ MaybeLocal<Object> StatementExecutionHelper::Run(Environment* env, | |||
| 2406 | 2406 | sqlite3_step(stmt); | |
| 2407 | 2407 | int r = sqlite3_reset(stmt); | |
| 2408 | 2408 | CHECK_ERROR_OR_THROW(isolate, db, r, SQLITE_OK, MaybeLocal<Object>()); | |
| 2409 | - Local<Object> result = Object::New(isolate); | ||
| 2409 | + | ||
| 2410 | 2410 | sqlite3_int64 last_insert_rowid = sqlite3_last_insert_rowid(db->Connection()); | |
| 2411 | 2411 | sqlite3_int64 changes = sqlite3_changes64(db->Connection()); | |
| 2412 | 2412 | Local<Value> last_insert_rowid_val; | |
@@ -2420,13 +2420,18 @@ MaybeLocal<Object> StatementExecutionHelper::Run(Environment* env, | |||
| 2420 | 2420 | changes_val = Number::New(isolate, changes); | |
| 2421 | 2421 | } | |
| 2422 | 2422 | ||
| 2423 | - if (result | ||
| 2424 | - ->Set(env->context(), | ||
| 2425 | - env->last_insert_rowid_string(), | ||
| 2426 | - last_insert_rowid_val) | ||
| 2427 | - .IsNothing() || | ||
| 2428 | - result->Set(env->context(), env->changes_string(), changes_val) | ||
| 2429 | - .IsNothing()) { | ||
| 2423 | + auto run_result_template = env->sqlite_run_result_template(); | ||
| 2424 | + if (run_result_template.IsEmpty()) { | ||
| 2425 | + static constexpr std::string_view run_result_keys[] = {"changes", | ||
| 2426 | + "lastInsertRowid"}; | ||
| 2427 | + run_result_template = DictionaryTemplate::New(isolate, run_result_keys); | ||
| 2428 | + env->set_sqlite_run_result_template(run_result_template); | ||
| 2429 | + } | ||
| 2430 | + | ||
| 2431 | + MaybeLocal<Value> values[] = {changes_val, last_insert_rowid_val}; | ||
| 2432 | + Local<Object> result; | ||
| 2433 | + if (!NewDictionaryInstance(env->context(), run_result_template, values) | ||
| 2434 | + .ToLocal(&result)) { | ||
| 2430 | 2435 | return MaybeLocal<Object>(); | |
| 2431 | 2436 | } | |
| 2432 | 2437 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments