Skip to content

Commit

Permalink
[RKOTLIN-1084] Remove deprecated property RealmClass.isEmbedded (#1754
Browse files Browse the repository at this point in the history
)
  • Loading branch information
clementetb authored May 21, 2024
1 parent f2f1c87 commit dccafa2
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 133 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ This release will bump the Realm file format 24. Opening a file with an older fo
* 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))
* 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))
* 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))
* Removed deprecated `RealmClass.isEmbedded`. Class embeddeness can be check with `RealmClassKind.EMBEDDED`. (Issue [#1753](https://github.com/realm/realm-kotlin/issues/1753) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1080))
* [Sync] Removed deprecated methods `User.identity` and `User.provider`, user identities can be accessed with the already existing `User.identities`. (Issue [#1751](https://github.com/realm/realm-kotlin/issues/1751) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1083))
* [Sync] `App.allUsers` does no longer return a map, but only a list of users known locally. (Issue [#1751](https://github.com/realm/realm-kotlin/issues/1751) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1083))
* [Sync ]Removed deprecated `DiscardUnsyncedChangesStrategy.onError`. (Issue [#1755](https://github.com/realm/realm-kotlin/issues/1755) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1085))

### Enhancements
* Support for RealmLists and RealmDictionaries in `RealmAny`. (Issue [#1434](https://github.com/realm/realm-kotlin/issues/1434))
Expand All @@ -18,6 +20,7 @@ This release will bump the Realm file format 24. Opening a file with an older fo
### Fixed
* Inserting the same typed link to the same key in a dictionary more than once would incorrectly create multiple backlinks to the object. This did not appear to cause any crashes later, but would have affecting explicit backlink count queries (eg: `...@links.@count`) and possibly notifications (Core Issue [realm/realm-core#7676](https://github.com/realm/realm-core/issues/7676) since v1.16.0).
* [Sync] Automatic client reset recovery would crash when recovering AddInteger instructions on a Mixed property if its type was changed to non-integer (Core issue [realm/realm-core#7683](https://github.com/realm/realm-core/pull/7683), since v0.11.0).
* [Sync] Typos [SubscriptionSetState.SUPERSEDED], [SyncTimeoutOptions.pingKeepalivePeriod] and [SyncTimeoutOptions.pongKeepalivePeriod]. (Issue [#1754](https://github.com/realm/realm-kotlin/pull/1754)

### Compatibility
* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public fun realmAnyListOf(vararg values: Any?): RealmAny =

/**
* Create a [RealmAny] containing a [RealmDictionary] with all argument values wrapped as
* [RealmAnys]s.
* [RealmAny]s.
* @param values entries of the dictionary.
*
* See [RealmAny.create] for [RealmDictionaries] constraints and examples of usage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ internal class ManagedRealmDictionary<V> constructor(
}

override fun changeFlow(scope: ProducerScope<MapChange<String, V>>): ChangeFlow<ManagedRealmMap<String, V>, MapChange<String, V>> =
RealmDictonaryChangeFlow<V>(scope)
RealmDictionaryChangeFlow<V>(scope)

override fun thaw(liveRealm: RealmReference): ManagedRealmDictionary<V>? {
return RealmInterop.realm_dictionary_resolve_in(nativePointer, liveRealm.dbPointer)
Expand All @@ -820,7 +820,7 @@ internal class ManagedRealmDictionary<V> constructor(
// TODO add equals and hashCode when https://github.com/realm/realm-kotlin/issues/1097 is fixed
}

internal class RealmDictonaryChangeFlow<V>(scope: ProducerScope<MapChange<String, V>>) :
internal class RealmDictionaryChangeFlow<V>(scope: ProducerScope<MapChange<String, V>>) :
ChangeFlow<ManagedRealmMap<String, V>, MapChange<String, V>>(scope) {
override fun initial(frozenRef: ManagedRealmMap<String, V>): MapChange<String, V> =
InitialDictionaryImpl(frozenRef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal abstract class BaseScalarQuery<E : BaseRealmObject> constructor(
}

/**
* Returns how many objects there are. The result is devliered as a [Long].
* Returns how many objects there are. The result is delivered as a [Long].
*/
internal class CountQuery<E : BaseRealmObject> constructor(
realmReference: RealmReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public data class RealmClassImpl(
it.type.run { this is ValuePropertyType && isPrimaryKey }
}

override val isEmbedded: Boolean = cinteropClass.isEmbedded

override val kind: RealmClassKind
get() = when {
cinteropClass.isEmbedded -> RealmClassKind.EMBEDDED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface RealmElementQuery<T : BaseRealmObject> : Deleteable {
* Finds all objects that fulfill the query conditions and returns them in a blocking fashion.
*
* It is not recommended launching heavy queries from the UI thread as it may result in a drop
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchroneously instead.
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchronously instead.
*
* @return a [RealmResults] instance containing matching objects. If no objects match the
* condition, an instance with zero objects is returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface RealmScalarQuery<T> {
* - `[sum]` returns the `type` specified in the call to said function
*
* It is not recommended launching heavy queries from the UI thread as it may result in a drop
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchroneously instead.
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchronously instead.
*
* @return a [T] containing the result of the scalar query.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface RealmSingleQuery<T : BaseRealmObject> : Deleteable {
* fashion.
*
* It is not recommended launching heavy queries from the UI thread as it may result in a drop
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchroneously instead.
* of frames or even ANRs. Use [asFlow] to obtain results of such queries asynchronously instead.
*
* @return a [RealmObject] or [EmbeddedRealmObject] instance or `null` if no object matches the condition.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ public interface RealmClass {
*/
public val primaryKey: RealmProperty?

/**
* Returns whether or not the class is embedded.
*/
@Deprecated("This property has been deprecated.", ReplaceWith("kind == RealmClassKind.EMBEDDED", "io.realm.kotlin.schema.RealmClassKind"))
public val isEmbedded: Boolean

/**
* Returns what type of Realm model class this is.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import kotlin.reflect.KClass
* `RealmAny` can contain other [RealmList] and [RealmDictionary] of [RealmAny]. This means that
* you can build nested collections inside a `RealmAny`-field.
* ```
* realmObjct.realmAnyField = realmAnyListOf(
* realmObject.realmAnyField = realmAnyListOf(
* // Primitive values can be added in collections
* 1,
* // Lists and dictionaries can contain other nested collection types
Expand Down Expand Up @@ -400,7 +400,7 @@ public interface RealmAny {
* ),
* realmDictionaryOf(
* "key1" to realmListOf(),
* "key2" to realmDictioneryOf())
* "key2" to realmDictionaryOf())
* )
* ```
*/
Expand All @@ -413,7 +413,7 @@ public interface RealmAny {
* To create a [RealmAny] containing a [RealmDictionary] of arbitrary values wrapped in
* [RealmAny]s use the [io.realm.kotlin.ext.realmAnyDictionaryOf].
*
* A `RealmDictionery<RealmAny?>` can contain all [RealmAny] types, also other collection types:
* A `RealmDictionary<RealmAny?>` can contain all [RealmAny] types, also other collection types:
* ```
* class SampleObject() : RealmObject {
* val realmAnyField: RealmAny? = null
Expand All @@ -422,7 +422,7 @@ public interface RealmAny {
*
* // Dictionaries can contain other collections, but only `RealmList<RealmAny>` and
* // `RealmDictionary<RealmAny>`.
* realmObjct.realmAnyField = realmAnyDictionaryOf(
* realmObject.realmAnyField = realmAnyDictionaryOf(
* "int" to 5,
* // Lists and dictionaries can contain other nested collection types
* "list" to realmListOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface RealmMap<K, V> : MutableMap<K, V> {
*
* @param keyPaths An optional list of model class properties that defines when a change to
* objects inside the map will result in a change being emitted. For maps, keypaths are
* evaluted based on the values of the map. This means that keypaths are only supported
* evaluated based on the values of the map. This means that keypaths are only supported
* for maps containing realm objects. Nested properties can be defined using a dotted syntax,
* e.g. `parent.child.name`. Wildcards `*` can be be used to capture all properties at a given
* level, e.g. `child.*` or `*.*`. If no keypaths are provided, changes to all top-level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
)
RealmInterop.realm_sync_client_config_set_ping_keepalive_period(
syncClientConfig,
syncTimeoutOptions.pingKeepalivePeriod.inWholeMilliseconds.toULong()
syncTimeoutOptions.pingKeepAlivePeriod.inWholeMilliseconds.toULong()
)
RealmInterop.realm_sync_client_config_set_pong_keepalive_timeout(
syncClientConfig,
syncTimeoutOptions.pongKeepalivePeriod.inWholeMilliseconds.toULong()
syncTimeoutOptions.pongKeepAlivePeriod.inWholeMilliseconds.toULong()
)
RealmInterop.realm_sync_client_config_set_fast_reconnect_limit(
syncClientConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal abstract class BaseSubscriptionSetImpl<T : BaseRealm>(
CoreSubscriptionSetState.RLM_SYNC_SUBSCRIPTION_ERROR ->
SubscriptionSetState.ERROR
CoreSubscriptionSetState.RLM_SYNC_SUBSCRIPTION_SUPERSEDED ->
SubscriptionSetState.SUPERCEDED
SubscriptionSetState.SUPERSEDED
CoreSubscriptionSetState.RLM_SYNC_SUBSCRIPTION_AWAITING_MARK ->
SubscriptionSetState.AWAITING_MARK
else -> TODO("Unsupported state: $coreState")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,6 @@ private class DiscardUnsyncedChangesHelper constructor(
appPointer: RealmAppPointer,
error: SyncError
) {
// If there is a user exception we appoint it as the cause of the client reset
strategy.onError(
session,
ClientResetRequiredException(appPointer, error)
)
// TODO call both onError and onManualResetFallback until the deprecated function is removed
strategy.onManualResetFallback(
session,
ClientResetRequiredException(appPointer, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public enum class SubscriptionSetState {
* are ignored by the server. Get the latest subscription set by calling
* [SubscriptionSet.refresh].
*/
SUPERCEDED,
SUPERSEDED,

/**
* The last bootstrap message containing the initial state for this subscription set has been received. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public interface ManuallyRecoverUnsyncedChangesStrategy : SyncClientResetStrateg
* the reset has concluded, [onAfterReset] will be invoked with both the instance before (read only)
* an instance of the final realm (mutable).
*
* In the event that discarding the unsynced data is not enough to resolve the reset the [onError]
* In the event that discarding the unsynced data is not enough to resolve the reset the [onManualResetFallback]
* callback will be invoked allowing to manually resolve the reset as it would be done in
* [ManuallyRecoverUnsyncedChangesStrategy.onClientReset].
*/
Expand All @@ -127,16 +127,6 @@ public interface DiscardUnsyncedChangesStrategy : AutomaticClientResetStrategy {
* @param after [MutableRealm] realm after the reset.
*/
public fun onAfterReset(before: TypedRealm, after: MutableRealm)

/**
* Callback that indicates the seamless Client reset couldn't complete. It should be handled
* as in [ManuallyRecoverUnsyncedChangesStrategy.onClientReset].
*
* @param session [SyncSession] during which this error happened.
* @param exception [ClientResetRequiredException] the specific Client Reset error.
*/
@Deprecated("Use onManualResetFallback()")
public fun onError(session: SyncSession, exception: ClientResetRequiredException)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public data class SyncTimeoutOptions(
* How long to wait between each ping message sent to the server. The client periodically
* sends ping messages to the server to check if the connection is still alive. Shorter
* periods make connection state change notifications more responsive at the cost of
* more trafic.
* more traffic.
*/
val pingKeepalivePeriod: Duration,
val pingKeepAlivePeriod: Duration,

/**
* How long to wait for the server to respond to a ping message. Shorter values make
* connection state change notifications more responsive, but increase the chance of
* spurious disconnections.
*/
val pongKeepalivePeriod: Duration,
val pongKeepAlivePeriod: Duration,

/**
* When a client first connects to the server, it downloads all data from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public class SyncTimeoutOptionsBuilder {
*
* @throws IllegalArgumentException if the duration is outside the allowed range.
*/
public var pingKeepalivePeriod: Duration = 1.minutes
public var pingKeepAlivePeriod: Duration = 1.minutes
set(value) {
Validation.require(value > 5.seconds) { "pingKeepalivePeriod must be a positive duration > 5 seconds. This was: $value" }
Validation.require(value > 5.seconds) { "pingKeepAlivePeriod must be a positive duration > 5 seconds. This was: $value" }
field = value
}

Expand All @@ -83,9 +83,9 @@ public class SyncTimeoutOptionsBuilder {
*
* @throws IllegalArgumentException if the duration is outside the allowed range.
*/
public var pongKeepalivePeriod: Duration = 2.minutes
public var pongKeepAlivePeriod: Duration = 2.minutes
set(value) {
Validation.require(value > 5.seconds) { "pongKeepalivePeriod must be a positive duration > 5 seconds. This was: $value" }
Validation.require(value > 5.seconds) { "pongKeepAlivePeriod must be a positive duration > 5 seconds. This was: $value" }
field = value
}

Expand Down Expand Up @@ -113,8 +113,8 @@ public class SyncTimeoutOptionsBuilder {
internal fun build() = SyncTimeoutOptions(
connectTimeout = this.connectTimeout,
connectionLingerTime = this.connectionLingerTime,
pingKeepalivePeriod = this.pingKeepalivePeriod,
pongKeepalivePeriod = this.pongKeepalivePeriod,
pingKeepAlivePeriod = this.pingKeepAlivePeriod,
pongKeepAlivePeriod = this.pongKeepAlivePeriod,
fastReconnectLimit = this.fastReconnectLimit
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,18 @@ class RealmSchemaTests {
val schemaVariationsDescriptor = schema[SCHEMA_VARIATION_CLASS_NAME]
?: fail("Couldn't find class")
assertEquals(SCHEMA_VARIATION_CLASS_NAME, schemaVariationsDescriptor.name)
assertFalse(schemaVariationsDescriptor.isEmbedded)
assertEquals(schemaVariationsDescriptor.kind, RealmClassKind.STANDARD)
assertEquals("string", schemaVariationsDescriptor.primaryKey?.name)

val sampleName = "Sample"
val sampleDescriptor = schema[sampleName] ?: fail("Couldn't find class")
assertEquals(sampleName, sampleDescriptor.name)
assertFalse(sampleDescriptor.isEmbedded)
assertNotEquals(sampleDescriptor.kind, RealmClassKind.EMBEDDED)
assertNull(sampleDescriptor.primaryKey)

val embeddedChildName = "EmbeddedChild"
val embeddedChildDescriptor = schema[embeddedChildName] ?: fail("Couldn't find class")
assertEquals(embeddedChildName, embeddedChildDescriptor.name)
assertTrue(embeddedChildDescriptor.isEmbedded)
assertEquals(embeddedChildDescriptor.kind, RealmClassKind.EMBEDDED)
assertNull(embeddedChildDescriptor.primaryKey)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ class AppConfigurationTests {
with(config.syncTimeoutOptions) {
assertEquals(2.minutes, connectTimeout)
assertEquals(30.seconds, connectionLingerTime)
assertEquals(1.minutes, pingKeepalivePeriod)
assertEquals(2.minutes, pongKeepalivePeriod)
assertEquals(1.minutes, pingKeepAlivePeriod)
assertEquals(2.minutes, pongKeepAlivePeriod)
assertEquals(1.minutes, fastReconnectLimit)
}
}
Expand All @@ -515,16 +515,16 @@ class AppConfigurationTests {
.syncTimeouts {
connectTimeout = 10.seconds
connectionLingerTime = 10.seconds
pingKeepalivePeriod = 10.seconds
pongKeepalivePeriod = 10.seconds
pingKeepAlivePeriod = 10.seconds
pongKeepAlivePeriod = 10.seconds
fastReconnectLimit = 10.seconds
}
.build()
with(config.syncTimeoutOptions) {
assertEquals(10.seconds, connectTimeout)
assertEquals(10.seconds, connectionLingerTime)
assertEquals(10.seconds, pingKeepalivePeriod)
assertEquals(10.seconds, pongKeepalivePeriod)
assertEquals(10.seconds, pingKeepAlivePeriod)
assertEquals(10.seconds, pongKeepAlivePeriod)
assertEquals(10.seconds, fastReconnectLimit)
}
}
Expand All @@ -540,13 +540,13 @@ class AppConfigurationTests {
connectionLingerTime = 0.seconds
}
assertFailsWith<IllegalArgumentException> {
pingKeepalivePeriod = 5.seconds
pingKeepAlivePeriod = 5.seconds
}
assertFailsWith<IllegalArgumentException> {
pongKeepalivePeriod = 5.seconds
pongKeepAlivePeriod = 5.seconds
}
assertFailsWith<IllegalArgumentException> {
pongKeepalivePeriod = 1.seconds
pongKeepAlivePeriod = 1.seconds
}
}
}
Expand Down
Loading

0 comments on commit dccafa2

Please sign in to comment.