SQLiteStmt::Use: Rename operator() -> apply()#491
Conversation
Using operator() caused very ugly clang formatting, e.g.
state.stmts->RegisterValidPath
.use()(printStorePath(info.path))(info.narHash.to_string(HashFormat::Base16, true))(
info.registrationTime == 0 ? time(nullptr) : info.registrationTime)(
info.deriver ? printStorePath(*info.deriver) : "",
(bool) info.deriver)(info.narSize, info.narSize != 0)(info.ultimate ? 1 : 0, info.ultimate)(
concatStringsSep(" ", Signature::toStrings(info.sigs)),
!info.sigs.empty())(renderContentAddress(info.ca), (bool) info.ca)
This was especially painful when there was a merge conflict involving
this type of code.
Now it looks like this:
state.stmts->RegisterValidPath.use()
.apply(printStorePath(info.path))
.apply(info.narHash.to_string(HashFormat::Base16, true))
.apply(info.registrationTime == 0 ? time(nullptr) : info.registrationTime)
.apply(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)
.apply(info.narSize, info.narSize != 0)
.apply(info.ultimate ? 1 : 0, info.ultimate)
.apply(concatStringsSep(" ", Signature::toStrings(info.sigs)), !info.sigs.empty())
.apply(renderContentAddress(info.ca), (bool) info.ca)
(cherry picked from commit 509aaa0)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR refactors SQLite statement parameter binding across the Nix codebase. The ChangesSQLiteStmt API migration to apply()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)src/libfetchers/cache.ccsrc/libfetchers/cache.cc:1:10: fatal error: 'nix/fetchers/cache.hh' file not found ... [truncated 2200 characters] ... ontend_decl.ml" (inlined), line 54, characters 4-52 src/libexpr/eval-cache.ccsrc/libexpr/eval-cache.cc:1:10: fatal error: 'nix/util/users.hh' file not found ... [truncated 2200 characters] ... l" (inlined), line 54, characters 4-52 src/libstore/nar-info-disk-cache.ccsrc/libstore/nar-info-disk-cache.cc:1:10: fatal error: 'nix/store/nar-info-disk-cache.hh' file not found ... [truncated 2200 characters] ... Frontend__CFrontend_decl.CFrontend_decl_funct.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Comment |
Motivation
Upstream NixOS#15989.
Using
operator()causes very ugly clang formatting, e.g.state.stmts->RegisterValidPath .use()(printStorePath(info.path))(info.narHash.to_string(HashFormat::Base16, true))( info.registrationTime == 0 ? time(nullptr) : info.registrationTime)( info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)(info.narSize, info.narSize != 0)(info.ultimate ? 1 : 0, info.ultimate)( concatStringsSep(" ", Signature::toStrings(info.sigs)), !info.sigs.empty())(renderContentAddress(info.ca), (bool) info.ca)This was especially painful when there was a merge conflict involving this type of code.
Now it looks like this:
state.stmts->RegisterValidPath.use() .apply(printStorePath(info.path)) .apply(info.narHash.to_string(HashFormat::Base16, true)) .apply(info.registrationTime == 0 ? time(nullptr) : info.registrationTime) .apply(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver) .apply(info.narSize, info.narSize != 0) .apply(info.ultimate ? 1 : 0, info.ultimate) .apply(concatStringsSep(" ", Signature::toStrings(info.sigs)), !info.sigs.empty()) .apply(renderContentAddress(info.ca), (bool) info.ca)Context
Summary by CodeRabbit