Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t force cast to NSComparisonPredicate in TERNARY operator #4232

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- Long-lasting TTID/TTFD spans (#4225). Avoid long TTID spans when the FrameTracker isn't running, which is the case when the app is in the background.
- Missing mach info for crash reports (#4230)
- Crash reports not generated on visionOS (#4229)

- Don’t force cast to `NSComparisonPredicate` in TERNARY operator (#4232)

### Improvements

Expand Down
9 changes: 4 additions & 5 deletions Sources/Sentry/SentryPredicateDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ - (NSString *)expressionDescription:(NSExpression *)predicate
break;
case NSConditionalExpressionType:
if (@available(macOS 10.11, *)) {
return [NSString
stringWithFormat:@"TERNARY(%@,%@,%@)",
[self comparisonPredicateDescription:(NSComparisonPredicate *)predicate.predicate],
[self expressionDescription:predicate.trueExpression],
[self expressionDescription:predicate.falseExpression]];
return [NSString stringWithFormat:@"TERNARY(%@,%@,%@)",
[self predicateDescription:predicate.predicate],
[self expressionDescription:predicate.trueExpression],
[self expressionDescription:predicate.falseExpression]];
} else {
// this is not supposed to happen, NSConditionalExpressionType was introduced in
// macOS 10.11 but we need this version check because cocoapod lint check is failing
Expand Down
5 changes: 5 additions & 0 deletions Tests/SentryTests/SentryPredicateDescriptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class SentryPredicateDescriptorTests: XCTestCase {
assertPredicate(predicate: pred, expectedResult: "field1 == %@ AND (field3 == %@ OR field2 == %@)")
}

func test_compoundInTenary() {
let pred = NSPredicate(format: "TERNARY(field1 > 10 AND field1 < 20, 1, 0) == 1")
assertPredicate(predicate: pred, expectedResult: "TERNARY(field1 > %@ AND field1 < %@,%@,%@) == %@")
}

func test_UNKNOWN() {
let pred = NSPredicate { _, _ in
return false
Expand Down
Loading