Skip to content

Commit 77512f7

Browse files
authored
Merge pull request #1716 from realm/next-major
[RKOTLIN-838] Collections in mixed
2 parents d8c839d + 2e893c7 commit 77512f7

File tree

51 files changed

+3295
-700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3295
-700
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
## 1.15.0-SNAPSHOT (YYYY-MM-DD)
22

3-
[!NOTE]
4-
This release will bump the Realm file format from version 23 to 24. Opening a file with an older format will automatically upgrade it from file format v10. If you want to upgrade from an earlier file format version you will have to use Realm Kotlin v1.13.1 or earlier. Downgrading to a previous file format is not possible.
3+
> [!NOTE]
4+
> This release will bump the Realm file format from version 23 to 24. Opening a file with an older format will automatically upgrade it from file format v10. If you want to upgrade from an earlier file format version you will have to use Realm Kotlin v1.13.1 or earlier. Downgrading to a previous file format is not possible.
55
66
### Breaking changes
77
* If you want to query using `@type` operation, you must use 'objectlink' to match links to objects. 'object' is reserved for dictionary types.
88
* Binary data and String data are now strongly typed for comparisons and queries. This change is especially relevant when querying for a string constant on a RealmAny property, as now only strings will be returned. If searching for Binary data is desired, then that type must be specified by the constant. In RQL the new way to specify a binary constant is to use `mixed = bin('xyz')` or `mixed = binary('xyz')`. (Core issue [realm/realm-core#6407](https://github.com/realm/realm-core/issues/6407)).
99

1010
### Enhancements
11+
* Support for RealmLists and RealmDictionaries in `RealmAny`. (Issue [#1434](https://github.com/realm/realm-kotlin/issues/1434))
1112
* Add support for using aggregate operations on RealmAny properties in queries (Core issue [realm/realm-core#7398](https://github.com/realm/realm-core/pull/7398))
1213
* Property keypath in RQL can be substituted with value given as argument. Use '$P<i>' in query string. (Core issue [realm/realm-core#7033](https://github.com/realm/realm-core/issues/7033))
1314
* You can now use query substitution for the @type argument (Core issue [realm/realm-core#7289](https://github.com/realm/realm-core/issues/7289))
@@ -16,7 +17,8 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
1617
* Index on list of strings property now supported (Core issue [realm/realm-core#7142](https://github.com/realm/realm-core/pull/7142))
1718
* Improved performance of RQL (parsed) queries on a non-linked string property using: >, >=, <, <=, operators and fixed behaviour that a null string should be evaulated as less than everything, previously nulls were not matched. (Core issue [realm/realm-core#3939](https://github.com/realm/realm-core/issues/3939).
1819
* Updated bundled OpenSSL version to 3.2.0 (Core issue [realm/realm-core#7303](https://github.com/realm/realm-core/pull/7303))
19-
* The default base url in `AppConfiguration` has been updated to point to `services.cloud.mongodb.com`. See https://www.mongodb.com/docs/atlas/app-services/domain-migration/ for more information. (Issue [#1685](https://github.com/realm/realm-kotlin/issues/1685))
20+
* Optimized `RealmList.indexOf()` and `RealmList.contains()` using Core implementation of operations instead of iterating elements and comparing them in Kotlin. (Issue [#1625](https://github.com/realm/realm-kotlin/pull/1666) [RKOTLIN-995](https://jira.mongodb.org/browse/RKOTLIN-995)).
21+
* [Sync] The default base url in `AppConfiguration` has been updated to point to `services.cloud.mongodb.com`. See https://www.mongodb.com/docs/atlas/app-services/domain-migration/ for more information. (Issue [#1685](https://github.com/realm/realm-kotlin/issues/1685))
2022

2123
### Fixed
2224
* Sorting order of strings has changed to use standard unicode codepoint order instead of grouping similar english letters together. A noticeable change will be from "aAbBzZ" to "ABZabz". (Core issue [realm/realm-core#2573](https://github.com/realm/realm-core/issues/2573))
@@ -49,7 +51,7 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
4951
* Minimum R8: 8.0.34.
5052

5153
### Internal
52-
* Updated to Realm Core 14.4.1 commit 374dd672af357732dccc135fecc905406fec3223.
54+
* Updated to Realm Core 14.5.1 commit 316889b967f845fbc10b4422f96c7eadd47136f2.
5355
* Deprecated Jenkins and switching to Github Action ([JIRA]https://jira.mongodb.org/browse/RKOTLIN-825).
5456
- Remove CMake required version.
5557
* Updated URL to documentation.

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ expect enum class ErrorCode : CodeDescription {
181181
RLM_ERR_MAINTENANCE_IN_PROGRESS,
182182
RLM_ERR_USERPASS_TOKEN_INVALID,
183183
RLM_ERR_INVALID_SERVER_RESPONSE,
184-
REALM_ERR_APP_SERVER_ERROR,
184+
RLM_ERR_APP_SERVER_ERROR,
185185
RLM_ERR_CALLBACK,
186186
RLM_ERR_UNKNOWN;
187187

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ expect enum class ValueType {
9595
RLM_TYPE_OBJECT_ID,
9696
RLM_TYPE_LINK,
9797
RLM_TYPE_UUID,
98+
RLM_TYPE_LIST,
99+
RLM_TYPE_DICTIONARY,
98100
}

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ expect val INVALID_PROPERTY_KEY: PropertyKey
5555
const val OBJECT_ID_BYTES_SIZE = 12
5656
const val UUID_BYTES_SIZE = 16
5757

58+
const val INDEX_NOT_FOUND = -1L
59+
5860
// Pure marker interfaces corresponding to the C-API realm_x_t struct types
5961
interface CapiT
6062
interface RealmConfigT : CapiT
@@ -304,6 +306,8 @@ expect object RealmInterop {
304306
isDefault: Boolean
305307
)
306308
fun realm_set_embedded(obj: RealmObjectPointer, key: PropertyKey): RealmObjectPointer
309+
fun realm_set_list(obj: RealmObjectPointer, key: PropertyKey): RealmListPointer
310+
fun realm_set_dictionary(obj: RealmObjectPointer, key: PropertyKey): RealmMapPointer
307311
fun realm_object_add_int(obj: RealmObjectPointer, key: PropertyKey, value: Long)
308312
fun <T> realm_object_get_parent(
309313
obj: RealmObjectPointer,
@@ -315,10 +319,17 @@ expect object RealmInterop {
315319
fun realm_get_backlinks(obj: RealmObjectPointer, sourceClassKey: ClassKey, sourcePropertyKey: PropertyKey): RealmResultsPointer
316320
fun realm_list_size(list: RealmListPointer): Long
317321
fun MemAllocator.realm_list_get(list: RealmListPointer, index: Long): RealmValue
322+
fun realm_list_find(list: RealmListPointer, value: RealmValue): Long
323+
fun realm_list_get_list(list: RealmListPointer, index: Long): RealmListPointer
324+
fun realm_list_get_dictionary(list: RealmListPointer, index: Long): RealmMapPointer
318325
fun realm_list_add(list: RealmListPointer, index: Long, transport: RealmValue)
319326
fun realm_list_insert_embedded(list: RealmListPointer, index: Long): RealmObjectPointer
320327
// Returns the element previously at the specified position
321328
fun realm_list_set(list: RealmListPointer, index: Long, inputTransport: RealmValue)
329+
fun realm_list_insert_list(list: RealmListPointer, index: Long): RealmListPointer
330+
fun realm_list_insert_dictionary(list: RealmListPointer, index: Long): RealmMapPointer
331+
fun realm_list_set_list(list: RealmListPointer, index: Long): RealmListPointer
332+
fun realm_list_set_dictionary(list: RealmListPointer, index: Long): RealmMapPointer
322333

323334
// Returns the newly inserted element as the previous embedded element is automatically delete
324335
// by this operation
@@ -350,10 +361,19 @@ expect object RealmInterop {
350361
dictionary: RealmMapPointer,
351362
mapKey: RealmValue
352363
): RealmValue
364+
fun realm_dictionary_find_list(
365+
dictionary: RealmMapPointer,
366+
mapKey: RealmValue
367+
): RealmListPointer
368+
fun realm_dictionary_find_dictionary(
369+
dictionary: RealmMapPointer,
370+
mapKey: RealmValue
371+
): RealmMapPointer
353372
fun MemAllocator.realm_dictionary_get(
354373
dictionary: RealmMapPointer,
355374
pos: Int
356375
): Pair<RealmValue, RealmValue>
376+
357377
fun MemAllocator.realm_dictionary_insert(
358378
dictionary: RealmMapPointer,
359379
mapKey: RealmValue,
@@ -375,6 +395,8 @@ expect object RealmInterop {
375395
dictionary: RealmMapPointer,
376396
mapKey: RealmValue
377397
): RealmValue
398+
fun realm_dictionary_insert_list(dictionary: RealmMapPointer, mapKey: RealmValue): RealmListPointer
399+
fun realm_dictionary_insert_dictionary(dictionary: RealmMapPointer, mapKey: RealmValue): RealmMapPointer
378400
fun realm_dictionary_get_keys(dictionary: RealmMapPointer): RealmResultsPointer
379401
fun realm_dictionary_resolve_in(
380402
dictionary: RealmMapPointer,
@@ -439,6 +461,8 @@ expect object RealmInterop {
439461

440462
// FIXME OPTIMIZE Get many
441463
fun MemAllocator.realm_results_get(results: RealmResultsPointer, index: Long): RealmValue
464+
fun realm_results_get_list(results: RealmResultsPointer, index: Long): RealmListPointer
465+
fun realm_results_get_dictionary(results: RealmResultsPointer, index: Long): RealmMapPointer
442466
fun realm_results_delete_all(results: RealmResultsPointer)
443467

444468
fun realm_get_object(realm: RealmPointer, link: Link): RealmObjectPointer

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ actual enum class ErrorCode(override val description: String, override val nativ
178178
RLM_ERR_MAINTENANCE_IN_PROGRESS("MaintenanceInProgress", realm_errno_e.RLM_ERR_MAINTENANCE_IN_PROGRESS),
179179
RLM_ERR_USERPASS_TOKEN_INVALID("UserpassTokenInvalid", realm_errno_e.RLM_ERR_USERPASS_TOKEN_INVALID),
180180
RLM_ERR_INVALID_SERVER_RESPONSE("InvalidServerResponse", realm_errno_e.RLM_ERR_INVALID_SERVER_RESPONSE),
181-
REALM_ERR_APP_SERVER_ERROR("AppServerError", realm_errno_e.RLM_ERR_APP_SERVER_ERROR),
181+
RLM_ERR_APP_SERVER_ERROR("AppServerError", realm_errno_e.RLM_ERR_APP_SERVER_ERROR),
182182
RLM_ERR_CALLBACK("Callback", realm_errno_e.RLM_ERR_CALLBACK),
183183
RLM_ERR_UNKNOWN("Unknown", realm_errno_e.RLM_ERR_UNKNOWN);
184184

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,15 @@ actual object RealmInterop {
503503
return LongPointerWrapper(realmc.realm_set_embedded(obj.cptr(), key.key))
504504
}
505505

506+
actual fun realm_set_list(obj: RealmObjectPointer, key: PropertyKey): RealmListPointer {
507+
realmc.realm_set_list(obj.cptr(), key.key)
508+
return realm_get_list(obj, key)
509+
}
510+
actual fun realm_set_dictionary(obj: RealmObjectPointer, key: PropertyKey): RealmMapPointer {
511+
realmc.realm_set_dictionary(obj.cptr(), key.key)
512+
return realm_get_dictionary(obj, key)
513+
}
514+
506515
actual fun realm_object_add_int(obj: RealmObjectPointer, key: PropertyKey, value: Long) {
507516
realmc.realm_object_add_int(obj.cptr(), key.key, value)
508517
}
@@ -560,13 +569,42 @@ actual object RealmInterop {
560569
return RealmValue(struct)
561570
}
562571

572+
actual fun realm_list_find(list: RealmListPointer, value: RealmValue): Long {
573+
val index = LongArray(1)
574+
val found = BooleanArray(1)
575+
realmc.realm_list_find(list.cptr(), value.value, index, found)
576+
return if (found[0]) {
577+
index[0]
578+
} else {
579+
INDEX_NOT_FOUND
580+
}
581+
}
582+
583+
actual fun realm_list_get_list(list: RealmListPointer, index: Long): RealmListPointer =
584+
LongPointerWrapper(realmc.realm_list_get_list(list.cptr(), index))
585+
586+
actual fun realm_list_get_dictionary(list: RealmListPointer, index: Long): RealmMapPointer =
587+
LongPointerWrapper(realmc.realm_list_get_dictionary(list.cptr(), index))
588+
563589
actual fun realm_list_add(list: RealmListPointer, index: Long, transport: RealmValue) {
564590
realmc.realm_list_insert(list.cptr(), index, transport.value)
565591
}
566592

567593
actual fun realm_list_insert_embedded(list: RealmListPointer, index: Long): RealmObjectPointer {
568594
return LongPointerWrapper(realmc.realm_list_insert_embedded(list.cptr(), index))
569595
}
596+
actual fun realm_list_insert_list(list: RealmListPointer, index: Long): RealmListPointer {
597+
return LongPointerWrapper(realmc.realm_list_insert_list(list.cptr(), index))
598+
}
599+
actual fun realm_list_insert_dictionary(list: RealmListPointer, index: Long): RealmMapPointer {
600+
return LongPointerWrapper(realmc.realm_list_insert_dictionary(list.cptr(), index))
601+
}
602+
actual fun realm_list_set_list(list: RealmListPointer, index: Long): RealmListPointer {
603+
return LongPointerWrapper(realmc.realm_list_set_list(list.cptr(), index))
604+
}
605+
actual fun realm_list_set_dictionary(list: RealmListPointer, index: Long): RealmMapPointer {
606+
return LongPointerWrapper(realmc.realm_list_set_dictionary(list.cptr(), index))
607+
}
570608

571609
actual fun realm_list_set(
572610
list: RealmListPointer,
@@ -724,6 +762,19 @@ actual object RealmInterop {
724762
return RealmValue(struct)
725763
}
726764

765+
actual fun realm_dictionary_find_list(
766+
dictionary: RealmMapPointer,
767+
mapKey: RealmValue
768+
): RealmListPointer {
769+
return LongPointerWrapper(realmc.realm_dictionary_get_list(dictionary.cptr(), mapKey.value))
770+
}
771+
actual fun realm_dictionary_find_dictionary(
772+
dictionary: RealmMapPointer,
773+
mapKey: RealmValue
774+
): RealmMapPointer {
775+
return LongPointerWrapper(realmc.realm_dictionary_get_dictionary(dictionary.cptr(), mapKey.value))
776+
}
777+
727778
actual fun MemAllocator.realm_dictionary_get(
728779
dictionary: RealmMapPointer,
729780
pos: Int
@@ -792,6 +843,14 @@ actual object RealmInterop {
792843
)
793844
}
794845

846+
actual fun realm_dictionary_insert_list(dictionary: RealmMapPointer, mapKey: RealmValue): RealmListPointer {
847+
return LongPointerWrapper(realmc.realm_dictionary_insert_list(dictionary.cptr(), mapKey.value))
848+
}
849+
850+
actual fun realm_dictionary_insert_dictionary(dictionary: RealmMapPointer, mapKey: RealmValue): RealmMapPointer {
851+
return LongPointerWrapper(realmc.realm_dictionary_insert_dictionary(dictionary.cptr(), mapKey.value))
852+
}
853+
795854
actual fun realm_dictionary_get_keys(dictionary: RealmMapPointer): RealmResultsPointer {
796855
val size = LongArray(1)
797856
val keysPointer = longArrayOf(0)
@@ -1053,7 +1112,7 @@ actual object RealmInterop {
10531112
deletions,
10541113
insertions,
10551114
modifications,
1056-
collectionWasDeleted
1115+
collectionWasDeleted,
10571116
)
10581117

10591118
val deletionStructs = realmc.new_valueArray(deletions[0].toInt())
@@ -1861,6 +1920,12 @@ actual object RealmInterop {
18611920
return RealmValue(value)
18621921
}
18631922

1923+
actual fun realm_results_get_list(results: RealmResultsPointer, index: Long): RealmListPointer =
1924+
LongPointerWrapper(realmc.realm_results_get_list(results.cptr(), index))
1925+
1926+
actual fun realm_results_get_dictionary(results: RealmResultsPointer, index: Long): RealmMapPointer =
1927+
LongPointerWrapper(realmc.realm_results_get_dictionary(results.cptr(), index))
1928+
18641929
actual fun realm_get_object(realm: RealmPointer, link: Link): RealmObjectPointer {
18651930
return LongPointerWrapper(realmc.realm_get_object(realm.cptr(), link.classKey.key, link.objKey))
18661931
}

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ValueType.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ actual enum class ValueType(override val nativeValue: Int) : NativeEnumerated {
2828
RLM_TYPE_DECIMAL128(realm_value_type_e.RLM_TYPE_DECIMAL128),
2929
RLM_TYPE_OBJECT_ID(realm_value_type_e.RLM_TYPE_OBJECT_ID),
3030
RLM_TYPE_LINK(realm_value_type_e.RLM_TYPE_LINK),
31-
RLM_TYPE_UUID(realm_value_type_e.RLM_TYPE_UUID);
31+
RLM_TYPE_UUID(realm_value_type_e.RLM_TYPE_UUID),
32+
RLM_TYPE_LIST(realm_value_type_e.RLM_TYPE_LIST),
33+
RLM_TYPE_DICTIONARY(realm_value_type_e.RLM_TYPE_DICTIONARY);
3234

3335
companion object {
3436
fun from(nativeValue: Int): ValueType = values().find {

packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ actual enum class ErrorCode(
182182
RLM_ERR_MAINTENANCE_IN_PROGRESS("MaintenanceInProgress", realm_errno.RLM_ERR_MAINTENANCE_IN_PROGRESS),
183183
RLM_ERR_USERPASS_TOKEN_INVALID("UserpassTokenInvalid", realm_errno.RLM_ERR_USERPASS_TOKEN_INVALID),
184184
RLM_ERR_INVALID_SERVER_RESPONSE("InvalidServerResponse", realm_errno.RLM_ERR_INVALID_SERVER_RESPONSE),
185-
REALM_ERR_APP_SERVER_ERROR("AppServerError", realm_errno.RLM_ERR_APP_SERVER_ERROR),
185+
RLM_ERR_APP_SERVER_ERROR("AppServerError", realm_errno.RLM_ERR_APP_SERVER_ERROR),
186186
RLM_ERR_CALLBACK("Callback", realm_errno.RLM_ERR_CALLBACK),
187187
RLM_ERR_UNKNOWN("Unknown", realm_errno.RLM_ERR_UNKNOWN);
188188

packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ actual enum class ValueType(
115115
RLM_TYPE_DECIMAL128(realm_value_type_e.RLM_TYPE_DECIMAL128),
116116
RLM_TYPE_OBJECT_ID(realm_value_type_e.RLM_TYPE_OBJECT_ID),
117117
RLM_TYPE_LINK(realm_value_type_e.RLM_TYPE_LINK),
118-
RLM_TYPE_UUID(realm_value_type_e.RLM_TYPE_UUID);
118+
RLM_TYPE_UUID(realm_value_type_e.RLM_TYPE_UUID),
119+
RLM_TYPE_LIST(realm_value_type_e.RLM_TYPE_LIST),
120+
RLM_TYPE_DICTIONARY(realm_value_type_e.RLM_TYPE_DICTIONARY),
121+
;
119122

120123
companion object {
121124
fun from(nativeValue: realm_value_type): ValueType = values().find {

0 commit comments

Comments
 (0)