FakePool SQL string-matching: detect column-value binding errors#59
Conversation
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR extends test DB stubs to record executed SQL and bound parameters to a shared ChangesSQL Parameter Capture and Binding Validation
sequenceDiagram
participant Test as TestFakePoolParamCapture
participant Cursor as _FakeCursor
participant Pool as FakePool
Test->>Cursor: execute(sql, params)
Cursor->>Pool: append (sql, params) to call_log
Test->>Pool: calls_matching(sql_fragment)
Pool-->>Test: return matching (sql, params)
Test->>Pool: assert_param_at(fragment, position, expected)
Pool-->>Test: assertion result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai full review again |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get the PR diff
gh pr view 59 --repo cppalliance/paperscout --json title,body,files,state,headRefNameLength of output: 1772 🏁 Script executed: #!/bin/bash
# Read the changed files
cat tests/conftest.py
echo "=== END OF conftest.py ==="
cat tests/test_storage.py
echo "=== END OF test_storage.py ==="Length of output: 29873
OverviewThe implementation is clean and purposeful. All acceptance criteria from issue
|
| Severity | File | Finding |
|---|---|---|
| Medium | conftest.py |
assert_param_at raises IndexError (not AssertionError) for out-of-bounds position |
| Nitpick | conftest.py |
call_log annotation (tuple) doesn't cover list params |
| Suggestion | test_storage.py |
test_call_log_records_sql_and_params could assert params are non-empty |
| Suggestion | test_storage.py |
Regression test docstring could clarify it tests the helper, not production code |
The assert_param_at bounds check is the only item worth addressing before merge. Everything else is polish.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/conftest.py`:
- Around line 208-210: The current assertion in the helper that checks parameter
index uses "assert position < len(params)" which still permits negative indices;
update the check to enforce a strict positional index by changing it to assert 0
<= position < len(params) and adjust the assertion message to reflect the new
precondition (e.g., mention valid range or that position must be non-negative
and less than len(params)) so functions like the one validating parameter bounds
reject negative positions instead of treating them as Python negative indices.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3f28b15e-b3a4-418e-951e-4965041922da
📒 Files selected for processing (2)
tests/conftest.pytests/test_storage.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/test_storage.py
Summary:
tests/conftest.py_FakeCursornow receives aFakePoolreference and logs everyexecute()call as(sql, params)inFakePool.call_log_FakeConnforwards the pool to_FakeCursorcalls_matching(sql_fragment)andassert_param_at(sql_fragment, position, expected)helpers onFakePooltests/test_storage.pyTestFakePoolParamCapturewith 8 tests covering:user_watchlistINSERT param order (positions 0–2)paper_cachekey bindingdiscovered_urlsurl andlast_modifiedbindingpytest.raises(AssertionError)Test results
All 61 tests in
tests/test_storage.pypass (53 existing + 8 new). No existing tests were modified. No production code changes.Related Issue
Summary by CodeRabbit