From 0b875df056e2a4c5c20ae9dff7b1a48a432d4448 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 23 Feb 2024 15:05:23 -0800 Subject: [PATCH] Upgrade to core 14 --- CHANGELOG.md | 5 +++-- Package.swift | 4 ++-- Realm/ObjectServerTests/RLMSyncTestCase.mm | 2 +- Realm/RLMBSON_Private.hpp | 3 +-- Realm/RLMLogger.mm | 4 ++-- Realm/RLMMongoCollection.mm | 2 +- Realm/RLMObservation.mm | 2 +- Realm/RLMQueryUtil.mm | 2 +- Realm/RLMSyncConfiguration.mm | 2 +- Realm/RLMSyncManager.mm | 6 +++--- Realm/RLMUtil.mm | 2 -- Realm/TestUtils/TestUtils.mm | 6 ++---- Realm/Tests/QueryTests.m | 1 - RealmSwift/Tests/SectionedResultsTests.swift | 15 +++++++-------- 14 files changed, 25 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef68a016c..e194508900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ x.y.z Release notes (yyyy-MM-dd) * None. ### Fixed -* ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?) -* None. +* Sorting on binary Data was done by comparing bytes as signed char rather than unsigned char, resulting in very strange orders (since sorting on Data was enabled in v6.0.4) +* Sorting on AnyRealmValue did not use a valid total ordering, and certain combinations of values could result in values not being sorted or potentially even crashes. The resolution for this will result in some previously-valid combinations of values of different types being sorted in different orders than previously (since the introduction of AnyRealmValue in 10.8.0). +* RLMSet/MutableSet was inconsistent about if it considered a String and a Data containing the utf-8 encoded bytes of that String to be equivalent. They are now always considered distinct. (since the introduction of sets in v10.8.0). diff --git a/Package.swift b/Package.swift index cead421a97..1013c37623 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription import Foundation -let coreVersion = Version("13.26.0") +let coreVersion = Version("14.0.0") let cocoaVersion = Version("10.47.0") let cxxSettings: [CXXSetting] = [ @@ -153,7 +153,7 @@ let package = Package( targets: ["Realm", "RealmSwift"]), ], dependencies: [ - .package(url: "https://github.com/realm/realm-core.git", exact: coreVersion) + .package(url: "https://github.com/realm/realm-core.git", revision: "c55b609f0cdcbafc7d680812f2808402c140ed65") ], targets: [ .target( diff --git a/Realm/ObjectServerTests/RLMSyncTestCase.mm b/Realm/ObjectServerTests/RLMSyncTestCase.mm index bc87d2e62f..c7a5c8e555 100644 --- a/Realm/ObjectServerTests/RLMSyncTestCase.mm +++ b/Realm/ObjectServerTests/RLMSyncTestCase.mm @@ -705,7 +705,7 @@ - (RLMMongoCollection *)collectionForType:(Class)type app:(RLMApp *)app { @end int64_t RLMGetClientFileIdent(RLMRealm *realm) { - return realm::SyncSession::OnlyForTesting::get_file_ident(*realm->_realm->sync_session()).ident; + return realm->_realm->sync_session()->get_file_ident().ident; } #endif // TARGET_OS_OSX diff --git a/Realm/RLMBSON_Private.hpp b/Realm/RLMBSON_Private.hpp index c5cc1a410d..c1f6c05ae4 100644 --- a/Realm/RLMBSON_Private.hpp +++ b/Realm/RLMBSON_Private.hpp @@ -21,8 +21,7 @@ namespace realm::bson { class Bson; -template class IndexedMap; -using BsonDocument = IndexedMap; +class BsonDocument; } realm::bson::Bson RLMConvertRLMBSONToBson(id b); diff --git a/Realm/RLMLogger.mm b/Realm/RLMLogger.mm index caa7988b3c..7cb27e6a1b 100644 --- a/Realm/RLMLogger.mm +++ b/Realm/RLMLogger.mm @@ -75,7 +75,7 @@ static RLMLogLevel logLevelForLevel(Level logLevel) { } struct CocoaLogger : public Logger { - void do_log(Level level, const std::string& message) override { + void do_log(const realm::util::LogCategory&, Level level, const std::string& message) override { NSLog(@"%@: %@", levelPrefix(level), RLMStringDataToNSString(message)); } }; @@ -83,7 +83,7 @@ void do_log(Level level, const std::string& message) override { class CustomLogger : public Logger { public: RLMLoggerFunction function; - void do_log(Level level, const std::string& message) override { + void do_log(const realm::util::LogCategory&, Level level, const std::string& message) override { @autoreleasepool { if (function) { function(logLevelForLevel(level), RLMStringDataToNSString(message)); diff --git a/Realm/RLMMongoCollection.mm b/Realm/RLMMongoCollection.mm index 7a3110d80d..52c9281c27 100644 --- a/Realm/RLMMongoCollection.mm +++ b/Realm/RLMMongoCollection.mm @@ -188,7 +188,7 @@ - (void)insertOneDocument:(NSDictionary> *)document - (void)insertManyDocuments:(NSArray> *> *)documents completion:(RLMMongoInsertManyBlock)completion { self.collection.insert_many(toBsonArray(documents), - [completion](std::vector insertedIds, + [completion](realm::bson::BsonArray insertedIds, std::optional error) { if (error) { return completion(nil, makeError(*error)); diff --git a/Realm/RLMObservation.mm b/Realm/RLMObservation.mm index 579f2b378b..c3e530e961 100644 --- a/Realm/RLMObservation.mm +++ b/Realm/RLMObservation.mm @@ -374,7 +374,7 @@ void RLMClearTable(RLMClassInfo &objectSchema) { } NSString *name = observer->columnName(link.origin_col_key); - if (observer->getRow().get_table()->get_column_type(link.origin_col_key) != type_LinkList) { + if (!link.origin_col_key.is_list()) { _changes.push_back({observer, name}); continue; } diff --git a/Realm/RLMQueryUtil.mm b/Realm/RLMQueryUtil.mm index cadaa44be0..0233ce5cbf 100644 --- a/Realm/RLMQueryUtil.mm +++ b/Realm/RLMQueryUtil.mm @@ -1660,7 +1660,7 @@ bool is_self_value_for_key_path_function_expression(NSExpression *expression) ColumnReference collectionColumn = column_reference_from_key_path(key_path_from_string(m_schema, objectSchema, keyPath), true); RLMPrecondition(collectionColumn.property().dictionary, @"Invalid predicate", @"Invalid keypath '%@': only dictionaries support subscript predicates.", functionExpression); - add_mixed_constraint(operatorType, options, collectionColumn.resolve().key(mapKey.UTF8String), right.constantValue); + add_mixed_constraint(operatorType, options, std::move(collectionColumn.resolve().key(mapKey.UTF8String)), right.constantValue); } void QueryBuilder::apply_function_expression(RLMObjectSchema *objectSchema, NSExpression *functionExpression, diff --git a/Realm/RLMSyncConfiguration.mm b/Realm/RLMSyncConfiguration.mm index f4b0f73e0a..10188dffc3 100644 --- a/Realm/RLMSyncConfiguration.mm +++ b/Realm/RLMSyncConfiguration.mm @@ -205,7 +205,7 @@ void RLMSetConfigInfoForClientResetCallbacks(realm::SyncConfig& syncConfig, RLMR - (id)partitionValue { if (!_config->partition_value.empty()) { - return RLMConvertBsonToRLMBSON(realm::bson::parse(_config->partition_value.c_str())); + return RLMConvertBsonToRLMBSON(realm::bson::parse(_config->partition_value)); } return nil; } diff --git a/Realm/RLMSyncManager.mm b/Realm/RLMSyncManager.mm index b4da2e6b2d..2f4bbbe515 100644 --- a/Realm/RLMSyncManager.mm +++ b/Realm/RLMSyncManager.mm @@ -73,7 +73,7 @@ RLMSyncLogLevel logLevelForLevel(Level logLevel) { #pragma mark - Loggers struct CocoaSyncLogger : public realm::util::Logger { - void do_log(Level, const std::string& message) override { + void do_log(const realm::util::LogCategory&, Level, const std::string& message) override { NSLog(@"Sync: %@", RLMStringDataToNSString(message)); } }; @@ -86,7 +86,7 @@ void do_log(Level, const std::string& message) override { struct CallbackLogger : public realm::util::Logger { RLMSyncLogFunction logFn; - void do_log(Level level, const std::string& message) override { + void do_log(const realm::util::LogCategory&, Level level, const std::string& message) override { @autoreleasepool { logFn(logLevelForLevel(level), RLMStringDataToNSString(message)); } @@ -202,7 +202,7 @@ - (void)resetForTesting { _logger = nil; _authorizationHeaderName = nil; _customRequestHeaders = nil; - _syncManager->reset_for_testing(); + _syncManager->tear_down_for_testing(); } - (std::shared_ptr)syncManager { diff --git a/Realm/RLMUtil.mm b/Realm/RLMUtil.mm index d99e402923..f10cd2fbde 100644 --- a/Realm/RLMUtil.mm +++ b/Realm/RLMUtil.mm @@ -453,8 +453,6 @@ id RLMMixedToObjc(realm::Mixed const& mixed, } case realm::type_UUID: return [[NSUUID alloc] initWithRealmUUID:mixed.get()]; - case realm::type_LinkList: - REALM_UNREACHABLE(); default: @throw RLMException(@"Invalid data type for RLMPropertyTypeAny property."); } diff --git a/Realm/TestUtils/TestUtils.mm b/Realm/TestUtils/TestUtils.mm index a8fe5817d4..49931177c8 100644 --- a/Realm/TestUtils/TestUtils.mm +++ b/Realm/TestUtils/TestUtils.mm @@ -183,10 +183,8 @@ bool RLMHasCachedRealmForPath(NSString *path) { std::string encoded_prefix, encoded_body; encoded_prefix.resize(realm::util::base64_encoded_size(unencoded_prefix.size())); encoded_body.resize(realm::util::base64_encoded_size(unencoded_body.size())); - realm::util::base64_encode(unencoded_prefix.data(), unencoded_prefix.size(), - &encoded_prefix[0], encoded_prefix.size()); - realm::util::base64_encode(unencoded_body.data(), unencoded_body.size(), - &encoded_body[0], encoded_body.size()); + realm::util::base64_encode(unencoded_prefix, encoded_prefix); + realm::util::base64_encode(unencoded_body, encoded_body); std::string suffix = "Et9HFtf9R3GEMA0IICOfFMVXY7kkTX1wr4qCyhIf58U"; return encoded_prefix + "." + encoded_body + "." + suffix; } diff --git a/Realm/Tests/QueryTests.m b/Realm/Tests/QueryTests.m index e8fcacbdb8..12996db4a6 100644 --- a/Realm/Tests/QueryTests.m +++ b/Realm/Tests/QueryTests.m @@ -3739,7 +3739,6 @@ - (void)testDictionaryQueryKeySubscript { RLMAssertCount(AllDictionariesObject, 0U, @"%K['aKey'] <[c] %@", property, values[0]); RLMAssertCount(AllDictionariesObject, 0U, @"%K['aKey'] <[cd] %@", property, values[0]); } else { - RLMAssertCount(AllDictionariesObject, 1U, @"%K['aKey'] = %@", property, values[0]); RLMAssertCount(AllDictionariesObject, 2U, @"%K['aKey'] != %@", property, values[0]); RLMAssertCount(AllDictionariesObject, 1U, @"%K['aKey'] =[c] %@", property, values[0]); diff --git a/RealmSwift/Tests/SectionedResultsTests.swift b/RealmSwift/Tests/SectionedResultsTests.swift index e52fddb76b..33b2f2879b 100644 --- a/RealmSwift/Tests/SectionedResultsTests.swift +++ b/RealmSwift/Tests/SectionedResultsTests.swift @@ -1256,7 +1256,6 @@ extension OptionalSectionedResultsTestData { } struct SectionedResultsTestDataInt: SectionedResultsTestData { - static var values: [Int] { [5, 4, 3, 2, 1] } @@ -1557,7 +1556,7 @@ struct SectionedResultsTestDataAnyRealmValue: SectionedResultsTestData { } static func orderedKeys(ascending: Bool) -> [String] { - return ["alphanumeric", "data"] + return ascending ? ["alphanumeric", "data"] : ["data", "alphanumeric"] } static func setupObject() -> ModernAllTypesObject { @@ -1604,14 +1603,14 @@ struct SectionedResultsTestDataBinary: SectionedResultsTestData { Data(base64Encoded: "abstract")!] } static var expectedSectionedValues: [String: [Data]] { - ["short": [Data(base64Encoded: "more")!, - Data(base64Encoded: "door")!], + ["short": [Data(base64Encoded: "door")!, + Data(base64Encoded: "more")!], "long": [Data(base64Encoded: "absolute")!, - Data(base64Encoded: "abstract")!]] + Data(base64Encoded: "abstract")!]] } static func orderedKeys(ascending: Bool) -> [String] { - return ["short", "long"] + ascending ? ["long", "short"] : ["short", "long"] } static func setupObject() -> ModernAllTypesObject { @@ -1644,13 +1643,13 @@ struct SectionedResultsTestDataOptionalBinary: OptionalSectionedResultsTestData Data(base64Encoded: "abstract")!] } static var expectedSectionedValuesOpt: [String?: [Data??]] { - ["short": [Data(base64Encoded: "more")!, Data(base64Encoded: "door")!], + ["short": [Data(base64Encoded: "door")!, Data(base64Encoded: "more")!], "long": [Data(base64Encoded: "absolute")!, Data(base64Encoded: "abstract")!], nil: [.some(.none)]] } static func orderedKeysOpt(ascending: Bool) -> [String?] { - return ascending ? [nil, "short", "long"] : ["short", "long", nil] + ascending ? [nil, "long", "short"] : ["short", "long", nil] } static func setupObject() -> ModernAllTypesObject {