Skip to content

Commit

Permalink
Merge pull request #2704 from cloudflare/shrima/fix-resetCounters-sqlite
Browse files Browse the repository at this point in the history
Reset row counters when creating Query using templates
  • Loading branch information
shrima-cf authored Sep 16, 2024
2 parents 4d9d2f1 + 3756650 commit e32364c
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 @@ -425,6 +425,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 e32364c

Please sign in to comment.