diff --git a/CHANGELOG.md b/CHANGELOG.md index 7123bde575..9b5c48fc9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,8 +113,6 @@ store. Xcode 15.1 is now the minimum supported version. * The `transferredBytes` and `transferrableBytes` fields on `Progress` have been deprecated in favor of `progressEstimate` which is a value between 0.0 and 1.0 indicating the estimated progress toward the upload/download transfer. ([#8476](https://github.com/realm/realm-swift/issues/8476)) - UUID/ObjectId types. ([.Net * #3566](https://github.com/realm/realm-dotnet/issues/3566)) -* Added `SyncConfiguration.initialSubscriptions` which describes the initial subscription configuration that was passed when constructing the `SyncConfiguration`. ([#8548](https://github.com/realm/realm-swift/issues/8548)) ### Fixed * `-[RLMUser allSessions]` did not include sessions which were currently diff --git a/Realm/RLMAccessor.mm b/Realm/RLMAccessor.mm index 821dfa096f..b52e7babd4 100644 --- a/Realm/RLMAccessor.mm +++ b/Realm/RLMAccessor.mm @@ -777,13 +777,13 @@ id RLMDynamicGetByName(__unsafe_unretained RLMObjectBase *const obj, } RLMArray *RLMGetSwiftPropertyArray(__unsafe_unretained RLMObjectBase *const obj, uint16_t key) { - return getCollection(obj, key); + return (RLMArray *)getCollection(obj, key); } RLMSet *RLMGetSwiftPropertySet(__unsafe_unretained RLMObjectBase *const obj, uint16_t key) { return getCollection(obj, key); } RLMDictionary *RLMGetSwiftPropertyMap(__unsafe_unretained RLMObjectBase *const obj, uint16_t key) { - return getCollection(obj, key); + return (RLMDictionary *)getCollection(obj, key); } void RLMSetSwiftPropertyNil(__unsafe_unretained RLMObjectBase *const obj, uint16_t key) { diff --git a/Realm/RLMQueryUtil.mm b/Realm/RLMQueryUtil.mm index a0a307f75c..c35f21c196 100644 --- a/Realm/RLMQueryUtil.mm +++ b/Realm/RLMQueryUtil.mm @@ -1849,10 +1849,11 @@ bool is_self_value_for_key_path_function_expression(NSExpression *expression) } } -// This function returns the nested subscripts from a NSPredicate with the following format `anyCol[0]['key']['all']` +// This function returns the nested subscripts from a NSPredicate with the following format `anyCol[0]['key'][#any]` // and its respective keypath (including any linked keypath) // This will iterate each argument of the NSExpression and its nested NSExpressions, takes the constant subscript -// and creates a PathElement to be used in the query. +// and creates a PathElement to be used in the query. If we use `#any` as a wildcard this will show in the parser +// predicate as NSKeyPathExpressionType. NSString* QueryBuilder::get_path_elements(std::vector &paths, NSExpression *expression) { NSString *keyPath = @""; for (NSUInteger i = 0; i < expression.arguments.count; i++) { @@ -1865,23 +1866,24 @@ bool is_self_value_for_key_path_function_expression(NSExpression *expression) paths.push_back(PathElement{[(NSNumber *)value intValue]}); } else if ([value isKindOfClass:[NSString class]]) { NSString *key = (NSString *)value; - if ([key isEqual:@"*"]) { - paths.push_back(PathElement{}); - } else { - paths.push_back(PathElement{key.UTF8String}); - } + paths.push_back(PathElement{key.UTF8String}); } else { throwException(@"Invalid subscript type", - @"Only `Strings` or index are allowed subscripts"); + @"Invalid subscript type '%@': Only `Strings` or index are allowed subscripts", expression); } } else if (expression.arguments[i].expressionType == NSKeyPathExpressionType) { - nestedKeyPath = expression.arguments[i].keyPath; + id path = [(id)expression.arguments[i] predicateFormat]; + if ([path isEqual:@"#any"]) { + paths.emplace_back(); + } else { + nestedKeyPath = path; + } } else { throwException(@"Invalid expression type", - @"Subscripts queries don't allow any other expression types"); + @"Invalid expression type '%@': Subscripts queries don't allow any other expression types", expression); } if ([nestedKeyPath length] > 0) { - keyPath = ([keyPath length] > 0) ? [NSString stringWithFormat:@"%@.%@", keyPath, nestedKeyPath] : [NSString stringWithFormat:@"%@", nestedKeyPath]; + keyPath = ([keyPath length] > 0) ? [NSString stringWithFormat:@"%@.%@", keyPath, nestedKeyPath] : nestedKeyPath; } } diff --git a/Realm/RLMUtil.mm b/Realm/RLMUtil.mm index 5ce1066acc..c075536dd1 100644 --- a/Realm/RLMUtil.mm +++ b/Realm/RLMUtil.mm @@ -48,7 +48,7 @@ #endif static inline RLMArray *asRLMArray(__unsafe_unretained id const value) { - return RLMDynamicCast(value) ?: RLMDynamicCast(value)._rlmCollection; + return RLMDynamicCast(value) ?: (RLMArray *)RLMDynamicCast(value)._rlmCollection; } static inline RLMSet *asRLMSet(__unsafe_unretained id const value) { @@ -56,7 +56,7 @@ } static inline RLMDictionary *asRLMDictionary(__unsafe_unretained id const value) { - return RLMDynamicCast(value) ?: RLMDynamicCast(value)._rlmCollection; + return RLMDynamicCast(value) ?: (RLMDictionary *)RLMDynamicCast(value)._rlmCollection; } static inline bool checkCollectionType(__unsafe_unretained id const collection, diff --git a/Realm/Tests/QueryTests.m b/Realm/Tests/QueryTests.m index 555343bd0b..8c62785c2c 100644 --- a/Realm/Tests/QueryTests.m +++ b/Realm/Tests/QueryTests.m @@ -3810,8 +3810,8 @@ - (void)testDictionarySubscriptThrowsException { @"Invalid keypath 'set[\"invalid\"]': only dictionaries and mixed support subscript predicates."); RLMAssertThrowsWithReason(([realm objects:@"OwnerObject" where:@"dog['dogName'] = NULL"]), @"Aggregate operations can only be used on key paths that include an collection property"); - RLMAssertThrowsWithReason(([realm objects:@"DictionaryPropertyObject" where:@"stringDictionary[%@] = NULL", [RLMObjectId objectId]]), - @"Only `Strings` or index are allowed subscripts"); + RLMAssertThrows(([realm objects:@"DictionaryPropertyObject" where:@"stringDictionary[%@] = NULL", [RLMObjectId objectId]]), + @"Invalid subscript type 'anyCol[[a-z0-9]+]': Only `Strings` or index are allowed subscripts"); RLMAssertThrowsWithReason(([realm objects:@"DictionaryPropertyObject" where:@"stringDictionary['aKey']['bKey'] = NULL"]), @"Invalid subscript size 'stringDictionary[\"aKey\"][\"bKey\"]': nested dictionaries queries are only allowed in mixed properties."); RLMAssertThrowsWithReason(([realm objects:@"DictionaryPropertyObject" where:@"stringDictionary[0] = NULL"]), @@ -3820,8 +3820,8 @@ - (void)testDictionarySubscriptThrowsException { - (void)testMixedSubscriptsThrowsException { RLMRealm *realm = [self realm]; - RLMAssertThrowsWithReason(([realm objects:@"AllTypesObject" where:@"anyCol[%@] = NULL", [NSDate date]]), - @"Only `Strings` or index are allowed subscripts"); + RLMAssertThrows(([realm objects:@"AllTypesObject" where:@"anyCol[%@] = NULL", [RLMObjectId objectId]]), + @"Invalid subscript type 'anyCol[[a-z0-9]+]': Only `Strings` or index are allowed subscripts"); } - (void)testCollectionsQueryAllValuesAllKeys { diff --git a/RealmSwift/AnyRealmValue.swift b/RealmSwift/AnyRealmValue.swift index 0d0e41d278..ab62cf1235 100644 --- a/RealmSwift/AnyRealmValue.swift +++ b/RealmSwift/AnyRealmValue.swift @@ -227,9 +227,9 @@ public enum AnyRealmValue: Hashable { hasher.combine(u.hashValue) case let .object(o): hasher.combine(o.hashValue) - case let .dictionary(d): + case .dictionary: hasher.combine(12) - case let .list(l): + case .list: hasher.combine(13) case .none: hasher.combine(14) diff --git a/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift b/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift index 9c15c4f5dc..a7d3808ce4 100644 --- a/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift +++ b/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift @@ -51,11 +51,9 @@ public extension ObjectiveCSupport { case let .object(o): return o case let .dictionary(d): - let rlmDictionary = Map._rlmFromObjc(d)?.rlmDictionary - return rlmDictionary + return d.rlmDictionary case let .list(l): - let rlmArray = List._rlmFromObjc(l)?.rlmArray - return rlmArray + return l.rlmArray default: return nil } diff --git a/RealmSwift/Query.swift b/RealmSwift/Query.swift index affb979171..f4fc6240f3 100644 --- a/RealmSwift/Query.swift +++ b/RealmSwift/Query.swift @@ -301,8 +301,8 @@ extension Query where T == AnyRealmValue { .init(appendKeyPath("['\(key)']", options: [.isPath])) } /// Query all indexes or keys in a mixed nested collecttion. - public var all: Query { - .init(appendKeyPath("['*']", options: [.isPath])) + public var any: Query { + .init(appendKeyPath("[#any]", options: [.isPath])) } } diff --git a/RealmSwift/RealmCollection.swift b/RealmSwift/RealmCollection.swift index 7cd4321315..4b1a328b03 100644 --- a/RealmSwift/RealmCollection.swift +++ b/RealmSwift/RealmCollection.swift @@ -84,16 +84,9 @@ public protocol _RealmMapValue { /// Advance to the next element and return it, or `nil` if no next element exists. public mutating func next() -> Element? { let next = generatorBase.next() - if let key = next as? Key { - if let value = collection[key as AnyObject].map(dynamicBridgeCast) as? Value { - return (key: key, value: value) - } else if let value = collection[key as AnyObject] as? RLMDictionary { - let map = Map(objc: value) - return (key: key, value: AnyRealmValue.dictionary(map) as! Value) - } else if let value = collection[key as AnyObject] as? RLMArray { - let list = List(collection: value) - return (key: key, value: AnyRealmValue.list(list) as! Value) - } + if let key = next as? Key, + let value = collection[key as AnyObject].map(Value._rlmFromObjc(_:)), let value { + return (key: key, value: value) } return nil } diff --git a/RealmSwift/Tests/MixedCollectionTest.swift b/RealmSwift/Tests/MixedCollectionTest.swift index 9daba0f427..807a57b509 100644 --- a/RealmSwift/Tests/MixedCollectionTest.swift +++ b/RealmSwift/Tests/MixedCollectionTest.swift @@ -33,7 +33,7 @@ class MixedCollectionTest: TestCase { XCTAssertEqual(o.anyValue.value.dictionaryValue?["key3"], .int(234)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key4"], .float(789.123)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key5"], .double(12345.678901)) - XCTAssertEqual(o.anyValue.value.dictionaryValue?["key6"], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.dictionaryValue?["key6"], .data(Data("a".utf8))) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key7"], .date(d)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key9"], .objectId(oid)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key10"], .uuid(uuid)) @@ -44,7 +44,7 @@ class MixedCollectionTest: TestCase { XCTAssertEqual(o.anyValue.value.dictionaryValue?["key3"]?.intValue, 234) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key4"]?.floatValue, 789.123) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key5"]?.doubleValue, 12345.678901) - XCTAssertEqual(o.anyValue.value.dictionaryValue?["key6"]?.dataValue, "a".data(using: .utf8)!) + XCTAssertEqual(o.anyValue.value.dictionaryValue?["key6"]?.dataValue, Data("a".utf8)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key7"]?.dateValue, d) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key8"]?.object(SwiftStringObject.self)?.stringCol, so.stringCol) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key9"]?.objectIdValue, oid) @@ -58,7 +58,7 @@ class MixedCollectionTest: TestCase { "key3": .int(234), "key4": .float(789.123), "key5": .double(12345.678901), - "key6": .data("a".data(using: .utf8)!), + "key6": .data(Data("a".utf8)), "key7": .date(d), "key8": .object(so), "key9": .objectId(oid), @@ -120,9 +120,9 @@ class MixedCollectionTest: TestCase { // Unmanaged Update o.anyValue.value.dictionaryValue?["key1"] = .object(so) - o.anyValue.value.dictionaryValue?["key2"] = .data("a".data(using: .utf8)!) + o.anyValue.value.dictionaryValue?["key2"] = .data(Data("a".utf8)) XCTAssertEqual(o.anyValue.value.dictionaryValue?["key1"]?.object(SwiftStringObject.self)?.stringCol, so.stringCol) - XCTAssertEqual(o.anyValue.value.dictionaryValue?["key2"], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.dictionaryValue?["key2"], .data(Data("a".utf8))) // Add mixed collection to object let realm = realmWithTestPath() @@ -130,7 +130,7 @@ class MixedCollectionTest: TestCase { realm.add(o) } XCTAssertEqual(o.anyValue.value.dictionaryValue?["key1"]?.object(SwiftStringObject.self)?.stringCol, so.stringCol) - XCTAssertEqual(o.anyValue.value.dictionaryValue?["key2"], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.dictionaryValue?["key2"], .data(Data("a".utf8))) // Update managed object try realm.write { @@ -232,7 +232,7 @@ class MixedCollectionTest: TestCase { XCTAssertEqual(o.anyValue.value.listValue?[2], .int(234)) XCTAssertEqual(o.anyValue.value.listValue?[3], .float(789.123)) XCTAssertEqual(o.anyValue.value.listValue?[4], .double(12345.678901)) - XCTAssertEqual(o.anyValue.value.listValue?[5], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.listValue?[5], .data(Data("a".utf8))) XCTAssertEqual(o.anyValue.value.listValue?[6], .date(d)) XCTAssertEqual(o.anyValue.value.listValue?[8], .objectId(oid)) XCTAssertEqual(o.anyValue.value.listValue?[9], .uuid(uuid)) @@ -243,7 +243,7 @@ class MixedCollectionTest: TestCase { XCTAssertEqual(o.anyValue.value.listValue?[2].intValue, 234) XCTAssertEqual(o.anyValue.value.listValue?[3].floatValue, 789.123) XCTAssertEqual(o.anyValue.value.listValue?[4].doubleValue, 12345.678901) - XCTAssertEqual(o.anyValue.value.listValue?[5].dataValue, "a".data(using: .utf8)!) + XCTAssertEqual(o.anyValue.value.listValue?[5].dataValue, Data("a".utf8)) XCTAssertEqual(o.anyValue.value.listValue?[6].dateValue, d) XCTAssertEqual(o.anyValue.value.listValue?[7].object(SwiftStringObject.self)?.stringCol, so.stringCol) XCTAssertEqual(o.anyValue.value.listValue?[8].objectIdValue, oid) @@ -257,7 +257,7 @@ class MixedCollectionTest: TestCase { .int(234), .float(789.123), .double(12345.678901), - .data("a".data(using: .utf8)!), + .data(Data("a".utf8)), .date(d), .object(so), .objectId(oid), @@ -319,9 +319,9 @@ class MixedCollectionTest: TestCase { // Unmanaged Update o.anyValue.value.listValue?[0] = .object(so) - o.anyValue.value.listValue?[1] = .data("a".data(using: .utf8)!) + o.anyValue.value.listValue?[1] = .data(Data("a".utf8)) XCTAssertEqual(o.anyValue.value.listValue?[0].object(SwiftStringObject.self)?.stringCol, so.stringCol) - XCTAssertEqual(o.anyValue.value.listValue?[1], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.listValue?[1], .data(Data("a".utf8))) // Add mixed collection to object let realm = realmWithTestPath() @@ -329,7 +329,7 @@ class MixedCollectionTest: TestCase { realm.add(o) } XCTAssertEqual(o.anyValue.value.listValue?[0].object(SwiftStringObject.self)?.stringCol, so.stringCol) - XCTAssertEqual(o.anyValue.value.listValue?[1], .data("a".data(using: .utf8)!)) + XCTAssertEqual(o.anyValue.value.listValue?[1], .data(Data("a".utf8))) // Update managed object try realm.write { diff --git a/RealmSwift/Tests/ObjectCreationTests.swift b/RealmSwift/Tests/ObjectCreationTests.swift index d920e2cb55..c6c6e2fcc1 100644 --- a/RealmSwift/Tests/ObjectCreationTests.swift +++ b/RealmSwift/Tests/ObjectCreationTests.swift @@ -1474,7 +1474,7 @@ class ObjectCreationTests: TestCase { case .object: return ["invalid", ["a"], ["boolCol": "a"], SwiftIntObject()] case .objectId: return ["invalid", 123] case .decimal128: return ["invalid"] - case .any: fatalError("not invalid") + case .any: return [MutableSet()] case .linkingObjects: fatalError("not supported") case .UUID: return ["invalid"] default: diff --git a/RealmSwift/Tests/QueryTests.swift b/RealmSwift/Tests/QueryTests.swift index 31c25654de..b96c6aa176 100644 --- a/RealmSwift/Tests/QueryTests.swift +++ b/RealmSwift/Tests/QueryTests.swift @@ -1204,36 +1204,20 @@ class QueryTests: TestCase { $0.anyCol[1] == .none } - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol.all == .none - } - - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol["*"] == .none + assertQuery("(anyCol[#any] == %@)", AnyRealmValue.none, count: 1) { + $0.anyCol.any == .none } assertQuery("(anyCol[0][1] == %@)", AnyRealmValue.int(99), count: 1) { $0.anyCol[0][1] == .int(99) } - assertQuery("(anyCol[0]['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol[0].all == .int(99) - } - - assertQuery("(anyCol[0]['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol[0]["*"] == .int(99) - } - assertQuery("(anyCol[0][0][1] == %@)", AnyRealmValue.double(76.54), count: 1) { $0.anyCol[0][0][1] == .double(76.54) } - assertQuery("(anyCol[0][0]['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol[0][0].all == .double(76.54) - } - - assertQuery("(anyCol[0][0]['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol[0][0]["*"] == .double(76.54) + assertQuery("(anyCol[0][0][#any] == %@)", AnyRealmValue.double(76.54), count: 1) { + $0.anyCol[0][0].any == .double(76.54) } assertQuery("(anyCol[0][0][0][0] == %@)", AnyRealmValue.string("john"), count: 1) { @@ -1244,20 +1228,12 @@ class QueryTests: TestCase { $0.anyCol[0][0][0][1] == .bool(false) } - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.string("john"), count: 1) { - $0.anyCol[0][0][0].all == .string("john") - } - - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.string("john"), count: 1) { - $0.anyCol[0][0][0]["*"] == .string("john") - } - - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.bool(false), count: 1) { - $0.anyCol[0][0][0].all == .bool(false) + assertQuery("(anyCol[0][0][0][#any] == %@)", AnyRealmValue.string("john"), count: 1) { + $0.anyCol[0][0][0].any == .string("john") } - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.bool(false), count: 1) { - $0.anyCol[0][0][0]["*"] == .bool(false) + assertQuery("(anyCol[0][0][0][#any] == %@)", AnyRealmValue.bool(false), count: 1) { + $0.anyCol[0][0][0].any == .bool(false) } assertQuery("(anyCol[0][1] >= %@)", AnyRealmValue.int(99), count: 1) { @@ -1287,36 +1263,24 @@ class QueryTests: TestCase { $0.anyCol["key1"] == .none } - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol.all == .none - } - - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol["*"] == .none + assertQuery("(anyCol[#any] == %@)", AnyRealmValue.none, count: 1) { + $0.anyCol.any == .none } assertQuery("(anyCol['key0']['key3'] == %@)", AnyRealmValue.int(99), count: 1) { $0.anyCol["key0"]["key3"] == .int(99) } - assertQuery("(anyCol['key0']['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all == .int(99) - } - - assertQuery("(anyCol['key0']['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] == .int(99) + assertQuery("(anyCol['key0'][#any] == %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any == .int(99) } assertQuery("(anyCol['key0']['key2']['key5'] == %@)", AnyRealmValue.double(76.54), count: 1) { $0.anyCol["key0"]["key2"]["key5"] == .double(76.54) } - assertQuery("(anyCol['key0']['key2']['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol["key0"]["key2"].all == .double(76.54) - } - - assertQuery("(anyCol['key0']['key2']['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol["key0"]["key2"]["*"] == .double(76.54) + assertQuery("(anyCol['key0']['key2'][#any] == %@)", AnyRealmValue.double(76.54), count: 1) { + $0.anyCol["key0"]["key2"].any == .double(76.54) } assertQuery("(anyCol['key0']['key2']['key4']['key6'] == %@)", AnyRealmValue.string("john"), count: 1) { @@ -1327,20 +1291,12 @@ class QueryTests: TestCase { $0.anyCol["key0"]["key2"]["key4"]["key7"] == .bool(false) } - assertQuery("(anyCol['key0']['*'] >= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all >= .int(99) - } - - assertQuery("(anyCol['key0']['*'] >= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] >= .int(99) - } - - assertQuery("(anyCol['key0']['*'] <= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all <= .int(99) + assertQuery("(anyCol['key0'][#any] >= %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any >= .int(99) } - assertQuery("(anyCol['key0']['*'] <= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] <= .int(99) + assertQuery("(anyCol['key0'][#any] <= %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any <= .int(99) } assertQuery("(anyCol['key0']['key3'] != %@)", AnyRealmValue.int(99), count: 0) { diff --git a/RealmSwift/Tests/QueryTests.swift.gyb b/RealmSwift/Tests/QueryTests.swift.gyb index b38ea90dc8..606fb6d161 100644 --- a/RealmSwift/Tests/QueryTests.swift.gyb +++ b/RealmSwift/Tests/QueryTests.swift.gyb @@ -515,36 +515,24 @@ class QueryTests: TestCase { $0.anyCol[1] == .none } - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol.all == .none - } - - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol["*"] == .none + assertQuery("(anyCol[#any] == %@)", AnyRealmValue.none, count: 1) { + $0.anyCol.any == .none } assertQuery("(anyCol[0][1] == %@)", AnyRealmValue.int(99), count: 1) { $0.anyCol[0][1] == .int(99) } - assertQuery("(anyCol[0]['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol[0].all == .int(99) - } - - assertQuery("(anyCol[0]['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol[0]["*"] == .int(99) + assertQuery("(anyCol[0][#any] == %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol[0].any == .int(99) } assertQuery("(anyCol[0][0][1] == %@)", AnyRealmValue.double(76.54), count: 1) { $0.anyCol[0][0][1] == .double(76.54) } - assertQuery("(anyCol[0][0]['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol[0][0].all == .double(76.54) - } - - assertQuery("(anyCol[0][0]['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol[0][0]["*"] == .double(76.54) + assertQuery("(anyCol[0][0][#any] == %@)", AnyRealmValue.double(76.54), count: 1) { + $0.anyCol[0][0],any == .double(76.54) } assertQuery("(anyCol[0][0][0][0] == %@)", AnyRealmValue.string("john"), count: 1) { @@ -555,20 +543,12 @@ class QueryTests: TestCase { $0.anyCol[0][0][0][1] == .bool(false) } - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.string("john"), count: 1) { - $0.anyCol[0][0][0].all == .string("john") + assertQuery("(anyCol[0][0][0][#any] == %@)", AnyRealmValue.string("john"), count: 1) { + $0.anyCol[0][0][0],any == .string("john") } - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.string("john"), count: 1) { - $0.anyCol[0][0][0]["*"] == .string("john") - } - - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.bool(false), count: 1) { - $0.anyCol[0][0][0].all == .bool(false) - } - - assertQuery("(anyCol[0][0][0]['*'] == %@)", AnyRealmValue.bool(false), count: 1) { - $0.anyCol[0][0][0]["*"] == .bool(false) + assertQuery("(anyCol[0][0][0][#any] == %@)", AnyRealmValue.bool(false), count: 1) { + $0.anyCol[0][0][0],any == .bool(false) } assertQuery("(anyCol[0][1] >= %@)", AnyRealmValue.int(99), count: 1) { @@ -598,11 +578,11 @@ class QueryTests: TestCase { $0.anyCol["key1"] == .none } - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { - $0.anyCol.all == .none + assertQuery("(anyCol[#any] == %@)", AnyRealmValue.none, count: 1) { + $0.anyCol,any == .none } - assertQuery("(anyCol['*'] == %@)", AnyRealmValue.none, count: 1) { + assertQuery("(anyCol[#any] == %@)", AnyRealmValue.none, count: 1) { $0.anyCol["*"] == .none } @@ -610,24 +590,16 @@ class QueryTests: TestCase { $0.anyCol["key0"]["key3"] == .int(99) } - assertQuery("(anyCol['key0']['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all == .int(99) - } - - assertQuery("(anyCol['key0']['*'] == %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] == .int(99) + assertQuery("(anyCol['key0'][#any] == %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any == .int(99) } assertQuery("(anyCol['key0']['key2']['key5'] == %@)", AnyRealmValue.double(76.54), count: 1) { $0.anyCol["key0"]["key2"]["key5"] == .double(76.54) } - assertQuery("(anyCol['key0']['key2']['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol["key0"]["key2"].all == .double(76.54) - } - - assertQuery("(anyCol['key0']['key2']['*'] == %@)", AnyRealmValue.double(76.54), count: 1) { - $0.anyCol["key0"]["key2"]["*"] == .double(76.54) + assertQuery("(anyCol['key0']['key2'][#any] == %@)", AnyRealmValue.double(76.54), count: 1) { + $0.anyCol["key0"]["key2"].any == .double(76.54) } assertQuery("(anyCol['key0']['key2']['key4']['key6'] == %@)", AnyRealmValue.string("john"), count: 1) { @@ -638,20 +610,12 @@ class QueryTests: TestCase { $0.anyCol["key0"]["key2"]["key4"]["key7"] == .bool(false) } - assertQuery("(anyCol['key0']['*'] >= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all >= .int(99) - } - - assertQuery("(anyCol['key0']['*'] >= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] >= .int(99) - } - - assertQuery("(anyCol['key0']['*'] <= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"].all <= .int(99) + assertQuery("(anyCol['key0'][#any] >= %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any >= .int(99) } - assertQuery("(anyCol['key0']['*'] <= %@)", AnyRealmValue.int(99), count: 1) { - $0.anyCol["key0"]["*"] <= .int(99) + assertQuery("(anyCol['key0'][#any] <= %@)", AnyRealmValue.int(99), count: 1) { + $0.anyCol["key0"].any <= .int(99) } assertQuery("(anyCol['key0']['key3'] != %@)", AnyRealmValue.int(99), count: 0) {