Skip to content

Commit 5c7c2a0

Browse files
authored
[RKOTLIN-1082] Remove RealmObjectId (#1748)
1 parent b875d7f commit 5c7c2a0

File tree

58 files changed

+175
-1608
lines changed

Some content is hidden

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

58 files changed

+175
-1608
lines changed

.github/actions/run-android-device-farm-test/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ runs:
4141
test_spec_file: test_spec-${{ inputs.app-id }}.yaml
4242
test_spec_type: APPIUM_PYTHON_TEST_SPEC
4343
remote_src: true
44+
timeout: 3600
4445
test_spec: |
4546
version: 0.1
4647
phases:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This release will bump the Realm file format 24. Opening a file with an older fo
66
### Breaking changes
77
* Removed property `RealmLog.level`. Log levels can be set with `RealmLog.setLevel`. (Issue [#1691](https://github.com/realm/realm-kotlin/issues/1691) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1038))
88
* Removed `LogConfiguration`. Log levels and custom loggers can be set with `RealmLog`. (Issue [#1691](https://github.com/realm/realm-kotlin/issues/1691) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1038))
9+
* Removed deprecated `io.realm.kotlin.types.ObjectId`. Use `org.mongodb.kbson.BsonObjectId` or its type alias `org.mongodb.kbson.ObjectId` instead. (Issue [#1749](https://github.com/realm/realm-kotlin/issues/1749) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1082))
910

1011
### Enhancements
1112
* Support for RealmLists and RealmDictionaries in `RealmAny`. (Issue [#1434](https://github.com/realm/realm-kotlin/issues/1434))

benchmarks/shared/src/commonMain/kotlin/io/realm/kotlin/benchmarks/Entities.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
package io.realm.kotlin.benchmarks
1717

1818
import io.realm.kotlin.ext.realmListOf
19-
import io.realm.kotlin.types.ObjectId
2019
import io.realm.kotlin.types.RealmInstant
2120
import io.realm.kotlin.types.RealmList
2221
import io.realm.kotlin.types.RealmObject
2322
import io.realm.kotlin.types.RealmUUID
2423
import io.realm.kotlin.types.annotations.PrimaryKey
24+
import org.mongodb.kbson.ObjectId
2525
import kotlin.reflect.KClass
2626

2727
val SCHEMAS = mapOf(
@@ -76,7 +76,7 @@ class WithPrimaryKey : RealmObject {
7676
var floatField: Float = 3.14f
7777
var doubleField: Double = 1.19840122
7878
var timestampField: RealmInstant = RealmInstant.from(100, 1000)
79-
var objectIdField: ObjectId = ObjectId.create()
79+
var objectIdField: ObjectId = ObjectId()
8080
var uuidField: RealmUUID = RealmUUID.random()
8181
var objectField: WithPrimaryKey? = null
8282
var objectListField: RealmList<Entity1> = realmListOf()
@@ -90,7 +90,7 @@ class Entity1 : RealmObject {
9090
var floatField: Float = 3.14f
9191
var doubleField: Double = 1.19840122
9292
var timestampField: RealmInstant = RealmInstant.from(100, 1000)
93-
var objectIdField: ObjectId = ObjectId.create()
93+
var objectIdField: ObjectId = ObjectId()
9494
var uuidField: RealmUUID = RealmUUID.random()
9595
var objectField: Entity1? = null
9696
var objectListField: RealmList<Entity1> = realmListOf()

examples/kmm-sample/shared/src/commonMain/kotlin/io/realm/example/kmmsample/AllTypes.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package io.realm.example.kmmsample
1919

2020
import io.realm.kotlin.ext.backlinks
2121
import io.realm.kotlin.ext.realmListOf
22-
import io.realm.kotlin.types.ObjectId
2322
import io.realm.kotlin.types.RealmInstant
2423
import io.realm.kotlin.types.RealmList
2524
import io.realm.kotlin.types.RealmObject
2625
import io.realm.kotlin.types.annotations.PrimaryKey
26+
import org.mongodb.kbson.ObjectId
2727

2828
// This class is included to make sure the compiler-plugin can handle various type, given the min/max
2929
// version of Kotlin this project is compiled against.
@@ -43,7 +43,7 @@ class AllTypes : RealmObject {
4343
var doubleField: Double = 0.0
4444
var floatField: Float = 0.0.toFloat()
4545
var realmInstantField: RealmInstant = RealmInstant.MIN
46-
var objectIdField: ObjectId = ObjectId.create()
46+
var objectIdField: ObjectId = ObjectId()
4747
var objectField: AllTypes? = null
4848

4949
// Nullable types
@@ -81,7 +81,7 @@ class AllTypes : RealmObject {
8181
var floatRealmListNullable: RealmList<Float?> = realmListOf(null)
8282
var realmInstantRealmList: RealmList<RealmInstant> = realmListOf(RealmInstant.MIN)
8383
var realmInstantRealmListNullable: RealmList<RealmInstant?> = realmListOf(null)
84-
var objectIdRealmList: RealmList<ObjectId> = realmListOf(ObjectId.create())
84+
var objectIdRealmList: RealmList<ObjectId> = realmListOf(ObjectId())
8585
var objectIdRealmListNullable: RealmList<ObjectId?> = realmListOf(null)
8686
var objectRealmList: RealmList<AllTypes> = realmListOf()
8787

packages/library-base/proguard-rules-consumer-common.pro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
## Keep Companion classes and class.Companion member of all classes that can be used in our API to
22
# allow calling realmObjectCompanionOrThrow and realmObjectCompanionOrNull on the classes
3-
-keep class io.realm.kotlin.types.ObjectId$Companion
4-
-keepclassmembers class io.realm.kotlin.types.ObjectId {
5-
io.realm.kotlin.types.ObjectId$Companion Companion;
6-
}
73
-keep class io.realm.kotlin.types.RealmInstant$Companion
84
-keepclassmembers class io.realm.kotlin.types.RealmInstant {
95
io.realm.kotlin.types.RealmInstant$Companion Companion;

packages/library-base/src/commonMain/kotlin/io/realm/kotlin/ext/ObjectIdExt.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/Converters.kt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import io.realm.kotlin.internal.interop.RealmValue
3333
import io.realm.kotlin.internal.interop.Timestamp
3434
import io.realm.kotlin.internal.interop.ValueType
3535
import io.realm.kotlin.types.BaseRealmObject
36-
import io.realm.kotlin.types.ObjectId
3736
import io.realm.kotlin.types.RealmAny
3837
import io.realm.kotlin.types.RealmInstant
3938
import io.realm.kotlin.types.RealmObject
@@ -99,8 +98,7 @@ public inline fun realmValueToFloat(transport: RealmValue): Float = transport.ge
9998
public inline fun realmValueToDouble(transport: RealmValue): Double = transport.getDouble()
10099
public inline fun realmValueToObjectId(transport: RealmValue): BsonObjectId =
101100
BsonObjectId(transport.getObjectIdBytes())
102-
public inline fun realmValueToRealmObjectId(transport: RealmValue): ObjectId =
103-
ObjectIdImpl(transport.getObjectIdBytes())
101+
104102
public inline fun realmValueToRealmUUID(transport: RealmValue): RealmUUID = RealmUUIDImpl(transport.getUUIDBytes())
105103
@OptIn(ExperimentalUnsignedTypes::class)
106104
public inline fun realmValueToDecimal128(transport: RealmValue): Decimal128 =
@@ -316,22 +314,7 @@ internal object ObjectIdConverter : PassThroughPublicConverter<BsonObjectId>() {
316314
override inline fun MemTrackingAllocator.toRealmValue(value: BsonObjectId?): RealmValue =
317315
objectIdTransport(value?.toByteArray())
318316
}
319-
320-
// Top level methods to allow inlining from compiler plugin
321-
public inline fun objectIdToRealmObjectId(value: BsonObjectId?): ObjectId? =
322-
value?.let { ObjectIdImpl(it.toByteArray()) }
323-
324-
internal object RealmObjectIdConverter : PassThroughPublicConverter<ObjectId>() {
325-
override inline fun fromRealmValue(realmValue: RealmValue): ObjectId? =
326-
if (realmValue.isNull()) null else realmValueToRealmObjectId(realmValue)
327-
328-
override inline fun MemTrackingAllocator.toRealmValue(value: ObjectId?): RealmValue =
329-
objectIdTransport(value?.let { it as ObjectIdImpl }?.bytes)
330-
}
331-
332317
// Top level methods to allow inlining from compiler plugin
333-
public inline fun realmObjectIdToObjectId(value: ObjectId?): BsonObjectId? =
334-
value?.let { BsonObjectId((it as ObjectIdImpl).bytes) }
335318

336319
internal object RealmUUIDConverter : PassThroughPublicConverter<RealmUUID>() {
337320
override inline fun fromRealmValue(realmValue: RealmValue): RealmUUID? =
@@ -365,8 +348,6 @@ internal val primitiveTypeConverters: Map<KClass<*>, RealmValueConverter<*>> =
365348
RealmInstant::class to RealmInstantConverter,
366349
RealmInstantImpl::class to RealmInstantConverter,
367350
BsonObjectId::class to ObjectIdConverter,
368-
ObjectId::class to RealmObjectIdConverter,
369-
ObjectIdImpl::class to RealmObjectIdConverter,
370351
RealmUUID::class to RealmUUIDConverter,
371352
RealmUUIDImpl::class to RealmUUIDConverter,
372353
ByteArray::class to ByteArrayConverter,

packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/ObjectIdImpl.kt

Lines changed: 0 additions & 111 deletions
This file was deleted.

packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmObjectHelper.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import io.realm.kotlin.schema.RealmStorageType
5656
import io.realm.kotlin.types.BaseRealmObject
5757
import io.realm.kotlin.types.EmbeddedRealmObject
5858
import io.realm.kotlin.types.MutableRealmInt
59-
import io.realm.kotlin.types.ObjectId
6059
import io.realm.kotlin.types.RealmAny
6160
import io.realm.kotlin.types.RealmDictionary
6261
import io.realm.kotlin.types.RealmInstant
@@ -212,11 +211,6 @@ internal object RealmObjectHelper {
212211
key,
213212
objectIdTransport(value.toByteArray())
214213
)
215-
is ObjectId -> setValueTransportByKey(
216-
obj,
217-
key,
218-
objectIdTransport((value as ObjectIdImpl).bytes)
219-
)
220214
is RealmUUID -> setValueTransportByKey(obj, key, uuidTransport(value.bytes))
221215
is RealmObjectInterop -> setValueTransportByKey(
222216
obj,

packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/schema/RealmStorageTypeImpl.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@ package io.realm.kotlin.internal.schema
1818

1919
import io.realm.kotlin.dynamic.DynamicMutableRealmObject
2020
import io.realm.kotlin.dynamic.DynamicRealmObject
21-
import io.realm.kotlin.internal.ObjectIdImpl
2221
import io.realm.kotlin.internal.RealmAnyImpl
2322
import io.realm.kotlin.internal.RealmInstantImpl
2423
import io.realm.kotlin.internal.RealmUUIDImpl
2524
import io.realm.kotlin.internal.dynamic.DynamicUnmanagedRealmObject
2625
import io.realm.kotlin.internal.interop.PropertyType
2726
import io.realm.kotlin.schema.RealmStorageType
2827
import io.realm.kotlin.types.BaseRealmObject
29-
import io.realm.kotlin.types.ObjectId
3028
import io.realm.kotlin.types.RealmAny
3129
import io.realm.kotlin.types.RealmInstant
3230
import io.realm.kotlin.types.RealmUUID
33-
import org.mongodb.kbson.BsonObjectId
3431
import kotlin.reflect.KClass
3532

3633
internal object RealmStorageTypeImpl {
@@ -56,8 +53,6 @@ internal object RealmStorageTypeImpl {
5653
}
5754

5855
internal fun <T : Any> KClass<T>.realmStorageType(): KClass<*> = when (this) {
59-
ObjectIdImpl::class -> BsonObjectId::class
60-
ObjectId::class -> BsonObjectId::class
6156
RealmUUIDImpl::class -> RealmUUID::class
6257
RealmInstantImpl::class -> RealmInstant::class
6358
DynamicRealmObject::class,

0 commit comments

Comments
 (0)