Skip to content

Commit

Permalink
Reset row counters when creating Query using templates
Browse files Browse the repository at this point in the history
  • Loading branch information
shrima-cf committed Sep 16, 2024
1 parent 529390d commit 3756650
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/workerd/util/sqlite-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,9 @@ KJ_TEST("SQLite read row counters (basic)") {
constexpr int dbRowCount = 1000;
auto insertStmt = db.prepare("INSERT INTO things (id, unindexed_int, value) VALUES (?, ?, ?)");
for (int i = 0; i < dbRowCount; i++) {
insertStmt.run(i, i * 1000, kj::str("value", i));
auto query = insertStmt.run(i, i * 1000, kj::str("value", i));
KJ_EXPECT(query.getRowsRead() == 1);
KJ_EXPECT(query.getRowsWritten() == 1);
}

// Sanity check that the inserts worked.
Expand Down
1 change: 1 addition & 0 deletions src/workerd/util/sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class SqliteDatabase::Query final: private ResetListener {
: ResetListener(db),
regulator(regulator),
maybeStatement(statement) {
resetRowCounters();
bindAll(std::index_sequence_for<Params...>(), kj::fwd<Params>(bindings)...);
}
template <typename... Params>
Expand Down

0 comments on commit 3756650

Please sign in to comment.