fix(repository): set where_added for ttfb filter#58
Open
fergusfinn wants to merge 1 commit intomainfrom
Open
Conversation
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in RequestFilter::build_query where the max_duration_to_first_byte_ms filter branch pushed a WHERE clause to the SQL query but failed to set where_added = true, causing any filter applied after it to also emit WHERE instead of AND, producing invalid SQL.
Changes:
- Adds
where_added = truein theelsebranch of themax_duration_to_first_byte_msfilter block, making it consistent with every other filter branch inbuild_query.
Comments suppressed due to low confidence (1)
src/repository.rs:218
- The test suite covers every other filter field (including
min_duration_ms/max_duration_ms) but there are no unit tests formin_duration_to_first_byte_msormax_duration_to_first_byte_ms. Without a dedicated test:
- The exact bug this PR fixes (missing
where_added = true) would not have been caught by the existing tests. - A future regression in the TTFB filter branch would similarly go undetected.
Please add tests analogous to test_duration_filters that exercise:
max_duration_to_first_byte_msas the sole filter (verifying it emitsWHERErather thanAND).- Both
min_duration_to_first_byte_msandmax_duration_to_first_byte_mstogether (verifying the first getsWHEREand the second getsAND). max_duration_to_first_byte_mscombined with another filter (e.g.,correlation_id) to verify theANDpath still works correctly.
if let Some(max_duration_to_first_byte) = self.max_duration_to_first_byte_ms {
if where_added {
query.push(" AND ");
} else {
query.push(" WHERE ");
where_added = true;
}
query.push("res.duration_to_first_byte_ms <= ");
query.push_bind(max_duration_to_first_byte);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
where_added = truein themax_duration_to_first_byte_msfilter branch when it introduces the first WHERE clauseTesting