diff --git a/CHANGELOG.md b/CHANGELOG.md index 688a54d6..6ef0ecca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ to upload multiple transactions in a batch. * Fix modifying severity of the global Kermit logger * Add `PowerSync` tag for the logs +* Fix `null` values in CRUD entries being reported as `"null"` strings. * [INTERNAL] Added helpers for Swift read and write lock exception handling. ## 1.4.0 diff --git a/core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt b/core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt index 4ba15d9b..566a2ae6 100644 --- a/core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt +++ b/core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt @@ -134,6 +134,11 @@ class CrudTest { ) batch.crud[0].previousValues shouldBe null + batch.crud[1].opData shouldBe + mapOf( + "a" to "te\"xt", + "b" to null, + ) batch.crud[1].opData?.typed shouldBe mapOf( "a" to "te\"xt", diff --git a/core/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt b/core/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt index 38499c8e..43e7e127 100644 --- a/core/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt +++ b/core/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt @@ -4,6 +4,7 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonNull import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive +import kotlinx.serialization.json.contentOrNull import kotlinx.serialization.json.jsonPrimitive import kotlin.experimental.ExperimentalObjCRefinement import kotlin.native.HiddenFromObjC @@ -47,11 +48,11 @@ internal class SerializedRow( private data class ToStringEntry( val inner: Map.Entry, -) : Map.Entry { +) : Map.Entry { override val key: String get() = inner.key - override val value: String - get() = inner.value.jsonPrimitive.content + override val value: String? + get() = inner.value.jsonPrimitive.contentOrNull } private class TypedRow(