Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Core 12.5.1 #967

Merged
merged 11 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Added support for `UUID` through a new property type: `RealmUUID`.
* Support for `Realm.writeCopyTo(configuration)`.
* [Sync] Add support for `User.delete()`, making it possible to delete user data on the server side (Issue [#491](https://github.com/realm/realm-kotlin/issues/491)).
* [Sync] It is now possible to create multiple anonymous users by specifying `Credentials.anonymous(reuseExisting = false)` when logging in to an App.

### Fixed
* `Realm.deleteRealm(config)` would throw an exception if the file didn't exist.
Expand All @@ -22,7 +23,7 @@
* Minimum Android SDK: 16.

### Internal
* None.
* Updated to Realm Core 12.5.1, commit 6f6a0f415bd33cf2ced4467e36a47f7c84f0a1d7.


## 1.0.2 (2022-08-05)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import io.realm.kotlin.internal.interop.realm_collection_type_e
import io.realm.kotlin.internal.interop.realm_property_flags_e
import io.realm.kotlin.internal.interop.realm_property_info_t
import io.realm.kotlin.internal.interop.realm_property_type_e
import io.realm.kotlin.internal.interop.realm_query_arg_t
import io.realm.kotlin.internal.interop.realm_schema_mode_e
import io.realm.kotlin.internal.interop.realm_schema_validation_mode_e
import io.realm.kotlin.internal.interop.realm_value_t
Expand Down Expand Up @@ -61,7 +62,7 @@ class CinteropTest {

@Test
fun version() {
assertEquals("12.1.0", realmc.realm_get_library_version())
assertEquals("12.5.1", realmc.realm_get_library_version())
}

// Test various schema migration with automatic flag:
Expand Down Expand Up @@ -125,19 +126,51 @@ class CinteropTest {
realmc.realm_open(config_2_renamed_col).also { realm ->
// make sure data was preserved
val foo_class = findTable(realm, "foo").key
var query: Long = realmc.realm_query_parse(realm, foo_class, "TRUEPREDICATE", 0, realm_value_t())
var query: Long = realmc.realm_query_parse(
realm,
foo_class,
"TRUEPREDICATE",
0,
realm_query_arg_t()
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(1, count[0])

// but data will not be migrated on the new column
query = realmc.realm_query_parse(realm, foo_class, "int_renamed == $0", 1, realm_value_t().apply { type = realm_value_type_e.RLM_TYPE_INT; integer = 42 })
query = realmc.realm_query_parse(
realm,
foo_class,
"int_renamed == $0",
1,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t().apply {
type = realm_value_type_e.RLM_TYPE_INT
integer = 42
}
}
)
realmc.realm_query_count(query, count)
assertEquals(0, count[0])

// old column was removed
assertFailsWith<RealmCoreInvalidQueryException> {
realmc.realm_query_parse(realm, foo_class, "int == $0", 1, realm_value_t().apply { type = realm_value_type_e.RLM_TYPE_INT; integer = 42 })
realmc.realm_query_parse(
realm,
foo_class,
"int == $0",
1,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t().apply {
type = realm_value_type_e.RLM_TYPE_INT
integer = 42
}
}
)
}.run {
assertEquals(
"[36]: 'foo' has no property: 'int'",
Expand Down Expand Up @@ -176,7 +209,17 @@ class CinteropTest {
realmc.realm_config_set_schema_version(config_2, 3)
realmc.realm_open(config_2).also { realm ->
// make sure data was preserved
val query: Long = realmc.realm_query_parse(realm, findTable(realm, "foo").key, "TRUEPREDICATE", 0, realm_value_t())
val query: Long = realmc.realm_query_parse(
realm,
findTable(realm, "foo").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(1, count[0])
Expand Down Expand Up @@ -211,7 +254,17 @@ class CinteropTest {
realmc.realm_config_set_schema_version(config_3, 4)
realmc.realm_open(config_3).also { realm ->
// make sure data was preserved
val query: Long = realmc.realm_query_parse(realm, findTable(realm, "foo").key, "TRUEPREDICATE", 0, realm_value_t())
val query: Long = realmc.realm_query_parse(
realm,
findTable(realm, "foo").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(1, count[0])
Expand All @@ -235,13 +288,33 @@ class CinteropTest {

realmc.realm_open(config_4).also { realm ->
// make sure data was preserved
var query: Long = realmc.realm_query_parse(realm, findTable(realm, "foo").key, "TRUEPREDICATE", 0, realm_value_t())
var query: Long = realmc.realm_query_parse(
realm,
findTable(realm, "foo").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(1, count[0])

// new class is available
query = realmc.realm_query_parse(realm, findTable(realm, "baz").key, "TRUEPREDICATE", 0, realm_value_t())
query = realmc.realm_query_parse(
realm,
findTable(realm, "baz").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
realmc.realm_query_count(query, count)
assertEquals(0, count[0])

Expand All @@ -262,7 +335,17 @@ class CinteropTest {

realmc.realm_open(config_5).also { realm ->
// make sure data was preserved
val query: Long = realmc.realm_query_parse(realm, findTable(realm, "foo").key, "TRUEPREDICATE", 0, realm_value_t())
val query: Long = realmc.realm_query_parse(
realm,
findTable(realm, "foo").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(1, count[0])
Expand Down Expand Up @@ -316,7 +399,17 @@ class CinteropTest {
realmc.realm_open(config_2).also { realm ->
// make sure the Realm is empty (reset)
val foo_class = findTable(realm, "foo")
val query: Long = realmc.realm_query_parse(realm, foo_class.key, "TRUEPREDICATE", 0, realm_value_t())
val query: Long = realmc.realm_query_parse(
realm,
foo_class.key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(0, count[0])
Expand Down Expand Up @@ -345,7 +438,17 @@ class CinteropTest {

realmc.realm_open(config_3).also { realm ->
// make sure the Realm is empty (reset)
val query: Long = realmc.realm_query_parse(realm, findTable(realm, "foo").key, "TRUEPREDICATE", 0, realm_value_t())
val query: Long = realmc.realm_query_parse(
realm,
findTable(realm, "foo").key,
"TRUEPREDICATE",
0,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t()
}
)
val count = LongArray(1)
realmc.realm_query_count(query, count)
assertEquals(0, count[0])
Expand Down Expand Up @@ -522,7 +625,20 @@ class CinteropTest {
// TODO API-FULL Find with primary key

// Query basics
val query: Long = realmc.realm_query_parse(realm, foo_info.key, "str == $0", 1, realm_value_t().apply { type = realm_value_type_e.RLM_TYPE_STRING; string = "Hello, World!" })
val query: Long = realmc.realm_query_parse(
realm,
foo_info.key,
"str == $0",
1,
realm_query_arg_t().apply {
nb_args = 1
is_list = false
arg = realm_value_t().apply {
type = realm_value_type_e.RLM_TYPE_STRING
string = "Hello, World!"
}
}
)

val count = LongArray(1)
realmc.realm_query_count(query, count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ expect object RealmInterop {
fun realm_is_frozen(realm: RealmPointer): Boolean
fun realm_close(realm: RealmPointer)
fun realm_delete_files(path: String)
fun realm_convert_with_config(realm: RealmPointer, config: RealmConfigurationPointer)
fun realm_convert_with_config(
realm: RealmPointer,
config: RealmConfigurationPointer,
mergeWithExisting: Boolean
)

fun realm_get_schema(realm: RealmPointer): RealmSchemaPointer
fun realm_get_schema_version(realm: RealmPointer): Long
Expand Down Expand Up @@ -386,7 +390,7 @@ expect object RealmInterop {
fun realm_app_config_set_base_url(appConfig: RealmAppConfigurationPointer, baseUrl: String)

// Credentials
fun realm_app_credentials_new_anonymous(): RealmCredentialsPointer
fun realm_app_credentials_new_anonymous(reuseExisting: Boolean): RealmCredentialsPointer
fun realm_app_credentials_new_email_password(username: String, password: String): RealmCredentialsPointer
fun realm_app_credentials_new_api_key(key: String): RealmCredentialsPointer
fun realm_app_credentials_new_apple(idToken: String): RealmCredentialsPointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package io.realm.kotlin.internal.interop.sync
*/
expect enum class AuthProvider {
RLM_AUTH_PROVIDER_ANONYMOUS,
RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE,
RLM_AUTH_PROVIDER_FACEBOOK,
RLM_AUTH_PROVIDER_GOOGLE,
RLM_AUTH_PROVIDER_APPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ expect enum class ProtocolSessionErrorCode {
RLM_SYNC_ERR_SESSION_OBJECT_ALREADY_EXISTS,
RLM_SYNC_ERR_SESSION_SERVER_PERMISSIONS_CHANGED,
RLM_SYNC_ERR_SESSION_INITIAL_SYNC_NOT_COMPLETED,
RLM_SYNC_ERR_SESSION_WRITE_NOT_ALLOWED;
RLM_SYNC_ERR_SESSION_WRITE_NOT_ALLOWED,
RLM_SYNC_ERR_SESSION_COMPENSATING_WRITE;

// Public visible description of the enum value
public val description: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ package io.realm.kotlin.internal.interop.sync
*/
expect enum class SyncSessionResyncMode {
RLM_SYNC_SESSION_RESYNC_MODE_MANUAL,
RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL;
RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL,
RLM_SYNC_SESSION_RESYNC_MODE_RECOVER,
RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD;

companion object {
fun fromInt(nativeValue: Int): SyncSessionResyncMode
Expand Down
Loading