diff --git a/CHANGELOG.md b/CHANGELOG.md index eba9f3de912..3906f10a0bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Sources/Sentry/SentryPredicateDescriptor.m b/Sources/Sentry/SentryPredicateDescriptor.m index ca6c3a77f95..229aeddd57f 100644 --- a/Sources/Sentry/SentryPredicateDescriptor.m +++ b/Sources/Sentry/SentryPredicateDescriptor.m @@ -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 diff --git a/Tests/SentryTests/SentryPredicateDescriptorTests.swift b/Tests/SentryTests/SentryPredicateDescriptorTests.swift index 05a01765223..67954f64cfe 100644 --- a/Tests/SentryTests/SentryPredicateDescriptorTests.swift +++ b/Tests/SentryTests/SentryPredicateDescriptorTests.swift @@ -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