Skip to content

Commit 61f354a

Browse files
committed
Fix null values in CRUD entries reported as strings
1 parent 4a42e5f commit 61f354a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
to upload multiple transactions in a batch.
77
* Fix modifying severity of the global Kermit logger
88
* Add `PowerSync` tag for the logs
9+
* Fix `null` values in CRUD entries being reported as `"null"` strings.
910
* [INTERNAL] Added helpers for Swift read and write lock exception handling.
1011

1112
## 1.4.0

core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class CrudTest {
134134
)
135135
batch.crud[0].previousValues shouldBe null
136136

137+
batch.crud[1].opData shouldBe mapOf(
138+
"a" to "te\"xt",
139+
"b" to null,
140+
)
137141
batch.crud[1].opData?.typed shouldBe
138142
mapOf(
139143
"a" to "te\"xt",

core/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlinx.serialization.json.JsonElement
44
import kotlinx.serialization.json.JsonNull
55
import kotlinx.serialization.json.JsonObject
66
import kotlinx.serialization.json.JsonPrimitive
7+
import kotlinx.serialization.json.contentOrNull
78
import kotlinx.serialization.json.jsonPrimitive
89
import kotlin.experimental.ExperimentalObjCRefinement
910
import kotlin.native.HiddenFromObjC
@@ -47,10 +48,10 @@ internal class SerializedRow(
4748

4849
private data class ToStringEntry(
4950
val inner: Map.Entry<String, JsonElement>,
50-
) : Map.Entry<String, String> {
51+
) : Map.Entry<String, String?> {
5152
override val key: String
5253
get() = inner.key
53-
override val value: String
54+
override val value: String?
5455
get() = inner.value.jsonPrimitive.content
5556
}
5657

0 commit comments

Comments
 (0)