Skip to content

Commit 4c98e84

Browse files
authored
fix(indexing): JsonElement as param of Partial.Update (#404)
1 parent 1306a1d commit 4c98e84

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

client/src/commonMain/kotlin/com/algolia/search/model/indexing/Partial.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ import kotlinx.serialization.KSerializer
1212
import kotlinx.serialization.Serializer
1313
import kotlinx.serialization.encoding.Decoder
1414
import kotlinx.serialization.encoding.Encoder
15-
import kotlinx.serialization.json.JsonArray
16-
import kotlinx.serialization.json.JsonElement
17-
import kotlinx.serialization.json.JsonObject
18-
import kotlinx.serialization.json.JsonPrimitive
19-
import kotlinx.serialization.json.buildJsonObject
20-
import kotlinx.serialization.json.jsonObject
21-
import kotlinx.serialization.json.put
15+
import kotlinx.serialization.json.*
2216

2317
/**
2418
* An object used to define a partial update operation with the [EndpointIndexing.partialUpdateObject] method.
@@ -36,7 +30,7 @@ public sealed class Partial {
3630
* Add or update the value of an attribute.
3731
* Several convenience constructors are available for each value type.
3832
*/
39-
public data class Update internal constructor(
33+
public data class Update(
4034
override val attribute: Attribute,
4135
override val value: JsonElement
4236
) : Partial() {

client/src/commonTest/kotlin/serialize/indexing/TestPartialUpdate.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ package serialize.indexing
33
import attributeA
44
import com.algolia.search.model.indexing.Partial
55
import com.algolia.search.serialize.internal.Key
6-
import kotlinx.serialization.json.JsonElement
7-
import kotlinx.serialization.json.add
8-
import kotlinx.serialization.json.buildJsonArray
9-
import kotlinx.serialization.json.buildJsonObject
10-
import kotlinx.serialization.json.put
6+
import kotlinx.serialization.json.*
117
import serialize.TestSerializer
128

139
internal class TestPartialUpdate : TestSerializer<Partial>(Partial) {
@@ -16,6 +12,7 @@ internal class TestPartialUpdate : TestSerializer<Partial>(Partial) {
1612
private val updateNumber = Partial.Update(attributeA, 0)
1713
private val updateArray = Partial.Update(attributeA, buildJsonArray { add(0) })
1814
private val updateObject = Partial.Update(attributeA, buildJsonObject { put("key", "value") })
15+
private val updateNull = Partial.Update(attributeA, JsonNull)
1916
private val increment = Partial.Increment(attributeA, 0)
2017
private val incrementFrom = Partial.IncrementFrom(attributeA, 0)
2118
private val incrementSet = Partial.IncrementSet(attributeA, 0)
@@ -32,6 +29,7 @@ internal class TestPartialUpdate : TestSerializer<Partial>(Partial) {
3229
updateNumber to toJson(updateNumber),
3330
updateObject to toJson(updateObject),
3431
updateArray to toJson(updateArray),
32+
updateNull to toJson(updateNull),
3533
increment to toJson(increment),
3634
incrementFrom to toJson(incrementFrom),
3735
incrementSet to toJson(incrementSet),
@@ -41,7 +39,7 @@ internal class TestPartialUpdate : TestSerializer<Partial>(Partial) {
4139
removeNumber to toJson(removeNumber),
4240
removeString to toJson(removeString),
4341
addUniqueString to toJson(addUniqueString),
44-
addUniqueNumber to toJson(addUniqueNumber)
42+
addUniqueNumber to toJson(addUniqueNumber),
4543
)
4644

4745
private fun toJson(partial: Partial): JsonElement {

0 commit comments

Comments
 (0)