-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix some static analyzer warnings #8249
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -731,16 +731,14 @@ Query make_diacritic_insensitive_constraint(NSPredicateOperatorType operatorType | |||||
void QueryBuilder::add_diacritic_sensitive_string_constraint(NSPredicateOperatorType operatorType, | ||||||
NSComparisonPredicateOptions predicateOptions, | ||||||
C&& column, T&& value) { | ||||||
if constexpr (is_any_v<C, Columns<Dictionary>>) { | ||||||
// This nesting isnt pretty but without it the compiler will complain about `T` having no known | ||||||
// conversion from Columns<StringData> to Mixed. This is due to the fact that all values on a | ||||||
// dictionary column are boxed in Mixed. | ||||||
if constexpr (is_any_v<T, Mixed, BinaryData, StringData>) { | ||||||
do_add_diacritic_sensitive_string_constraint(operatorType, predicateOptions, std::forward<C>(column), value); | ||||||
} | ||||||
|
||||||
if constexpr (is_any_v<C, Columns<Dictionary>> && is_any_v<T, Columns<StringData>, Columns<BinaryData>>) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just check if T is mixed and throw otherwise |
||||||
// Core only implements these for Columns<Mixed> due to Dictionary being Mixed internall | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
throwException(@"Unsupported predicate", | ||||||
@"String comparisons on a Dictionary and another property are only implemented for AnyRealmValue properties."); | ||||||
} | ||||||
else { | ||||||
do_add_diacritic_sensitive_string_constraint(operatorType, predicateOptions, std::forward<C>(column), value); | ||||||
do_add_diacritic_sensitive_string_constraint(operatorType, predicateOptions, std::forward<C>(column), std::forward<T>(value)); | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -749,7 +747,7 @@ Query make_diacritic_insensitive_constraint(NSPredicateOperatorType operatorType | |||||
NSComparisonPredicateOptions predicateOptions, | ||||||
C&& column, T&& value) { | ||||||
if (!(predicateOptions & NSDiacriticInsensitivePredicateOption)) { | ||||||
add_diacritic_sensitive_string_constraint(operatorType, predicateOptions, std::forward<C>(column), std::move(value)); | ||||||
add_diacritic_sensitive_string_constraint(operatorType, predicateOptions, std::forward<C>(column), std::forward<T>(value)); | ||||||
return; | ||||||
} | ||||||
|
||||||
|
@@ -998,7 +996,7 @@ void convert_null(T&& value, Fn&& fn) { | |||||
fn(null()); | ||||||
} | ||||||
else { | ||||||
fn(value); | ||||||
fn(std::forward<T>(value)); | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -1382,15 +1380,15 @@ auto collection_operation_expr(CollectionOperation operation) { | |||||
CollectionOperation const& collectionOperation, R&& rhs, | ||||||
NSComparisonPredicateOptions options) | ||||||
{ | ||||||
convert_null(rhs, [&](auto&& rhs) { | ||||||
convert_null(std::forward<R>(rhs), [&]<typename T>(T&& rhs) { | ||||||
if (collectionOperation.link_column().is_link()) { | ||||||
add_collection_operation_constraint<Operation, true, false>(operatorType, collectionOperation, std::move(rhs), options); | ||||||
add_collection_operation_constraint<Operation, true, false>(operatorType, collectionOperation, std::forward<T>(rhs), options); | ||||||
} | ||||||
else if (collectionOperation.column().property().dictionary) { | ||||||
add_collection_operation_constraint<Operation, false, true>(operatorType, collectionOperation, std::move(rhs), options); | ||||||
add_collection_operation_constraint<Operation, false, true>(operatorType, collectionOperation, std::forward<T>(rhs), options); | ||||||
} | ||||||
else { | ||||||
add_collection_operation_constraint<Operation, false, false>(operatorType, collectionOperation, std::move(rhs), options); | ||||||
add_collection_operation_constraint<Operation, false, false>(operatorType, collectionOperation, std::forward<T>(rhs), options); | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
@@ -1420,8 +1418,8 @@ void get_collection_type(__unsafe_unretained RLMProperty *prop, Fn&& fn) { | |||||
auto& column = collectionOperation.link_column(); | ||||||
RLMPropertyType type = column.type(); | ||||||
auto rhsValue = value_of_type<Int>(rhs); | ||||||
auto continuation = [&](auto t) { | ||||||
add_numeric_constraint(type, operatorType, column.resolve<std::decay_t<decltype(*t)>>().size(), rhsValue); | ||||||
auto continuation = [&]<typename T>(T *) { | ||||||
add_numeric_constraint(type, operatorType, column.resolve<T>().size(), rhsValue); | ||||||
}; | ||||||
|
||||||
switch (type) { | ||||||
|
@@ -1453,16 +1451,16 @@ void get_collection_type(__unsafe_unretained RLMProperty *prop, Fn&& fn) { | |||||
} | ||||||
} | ||||||
case CollectionOperation::Minimum: | ||||||
add_collection_operation_constraint<CollectionOperation::Minimum>(operatorType, collectionOperation, std::move(rhs), comparisonOptions); | ||||||
add_collection_operation_constraint<CollectionOperation::Minimum>(operatorType, collectionOperation, std::forward<R>(rhs), comparisonOptions); | ||||||
break; | ||||||
case CollectionOperation::Maximum: | ||||||
add_collection_operation_constraint<CollectionOperation::Maximum>(operatorType, collectionOperation, std::move(rhs), comparisonOptions); | ||||||
add_collection_operation_constraint<CollectionOperation::Maximum>(operatorType, collectionOperation, std::forward<R>(rhs), comparisonOptions); | ||||||
break; | ||||||
case CollectionOperation::Sum: | ||||||
add_collection_operation_constraint<CollectionOperation::Sum>(operatorType, collectionOperation, std::move(rhs), comparisonOptions); | ||||||
add_collection_operation_constraint<CollectionOperation::Sum>(operatorType, collectionOperation, std::forward<R>(rhs), comparisonOptions); | ||||||
break; | ||||||
case CollectionOperation::Average: | ||||||
add_collection_operation_constraint<CollectionOperation::Average>(operatorType, collectionOperation, std::move(rhs), comparisonOptions); | ||||||
add_collection_operation_constraint<CollectionOperation::Average>(operatorType, collectionOperation, std::forward<R>(rhs), comparisonOptions); | ||||||
break; | ||||||
case CollectionOperation::AllKeys: { | ||||||
// BETWEEN and IN are not supported by @allKeys as the parsing for collection | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1603,6 +1603,10 @@ - (void)testConvertToEmbeddedAddingMoreLinks { | |
XCTAssertNotNil(oldObject); | ||
XCTAssertNotNil(newObject); | ||
RLMObject *childObject = newObject[@"object"]; | ||
XCTAssertNotNil(childObject); | ||
if (childObject == nil) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the above assertion fails, is this even run? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The rest of the test continues running even if an XCTest assertion fails. |
||
return; | ||
} | ||
[migration createObject:EmbeddedIntParentObject.className withValue:@[@43, childObject, NSNull.null]]; | ||
}]; | ||
}]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tag the issue which reported this?