diff --git a/README.md b/README.md index 76880b242..89020200b 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ documentRef.updateFields { "otherField".to(IntAsStringSerializer(), 1) // Overwrite build settings. All fields added after this will have these build settings applied - buildSettings = { + encodeNextWith { encodeDefaults = true serializersModule = module } @@ -215,7 +215,7 @@ query.orderBy("field", "otherField", "city").startAtFieldValues { // similar syn add(1, IntAsStringSerializer()) // Overwrite build settings. All field values added after this will have these build settings applied - buildSettings = { + encodeNextWith { encodeDefaults = true serializersModule = module } diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api index 50a8e7fed..f843fe52a 100644 --- a/firebase-firestore/api/android/firebase-firestore.api +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -172,13 +172,15 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public final class dev/gitlive/firebase/firestore/FieldValuesDSL { public final fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V } public final class dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL { - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V @@ -238,9 +240,10 @@ public final class dev/gitlive/firebase/firestore/FilterBuilder { public final fun contains (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun containsAny (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun containsAny (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V public final fun equalTo (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun equalTo (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; public final fun greaterThan (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun greaterThan (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun greaterThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; @@ -260,7 +263,7 @@ public final class dev/gitlive/firebase/firestore/FilterBuilder { public final fun notInArray (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun notInArray (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun or (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$Or; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V } public final class dev/gitlive/firebase/firestore/FirebaseFirestore { diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api index 1deee3348..3f1d200c4 100644 --- a/firebase-firestore/api/jvm/firebase-firestore.api +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -172,13 +172,15 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public final class dev/gitlive/firebase/firestore/FieldValuesDSL { public final fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V } public final class dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL { - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V @@ -238,9 +240,10 @@ public final class dev/gitlive/firebase/firestore/FilterBuilder { public final fun contains (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun containsAny (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun containsAny (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun encodeNextWith (Lkotlin/jvm/functions/Function1;)V public final fun equalTo (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun equalTo (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; - public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun getEncodeNextWith ()Lkotlin/jvm/functions/Function1; public final fun greaterThan (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun greaterThan (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun greaterThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; @@ -260,7 +263,7 @@ public final class dev/gitlive/firebase/firestore/FilterBuilder { public final fun notInArray (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun notInArray (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; public final fun or (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$Or; - public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun setEncodeNextWith (Lkotlin/jvm/functions/Function1;)V } public final class dev/gitlive/firebase/firestore/FirebaseFirestore { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt index f0d851a42..d2f119641 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt @@ -11,20 +11,25 @@ public class FieldValuesDSL internal constructor() { internal val fieldValues: MutableList = mutableListOf() + @PublishedApi + internal var encodeNextWith: EncodeSettings.Builder.() -> Unit = { + encodeDefaults = true + } + /** - * The [EncodeSettings.Builder] to apply to the next field values added. + * Sets the [EncodeSettings.Builder] to apply to the next field values added. * Updating this value will only influence the encoding of field values not yet added to the update. * This allows for custom encoding per value, e.g. * * ``` - * buildSettings = { encodeDefaults = true } + * encodeNextWith { encodeDefaults = true } * add(ClassWithDefaults()) - * buildSettings = { encodeDefaults = false } + * encodeNextWith { encodeDefaults = false } * add(ClassWithDefaults()) * ``` */ - public var buildSettings: EncodeSettings.Builder.() -> Unit = { - encodeDefaults = true + public fun encodeNextWith(builder: EncodeSettings.Builder.() -> Unit) { + encodeNextWith = builder } /** @@ -33,7 +38,7 @@ public class FieldValuesDSL internal constructor() { * @param value the value [T] to add */ public inline fun add(value: T) { - addEncoded(encode(value, buildSettings)!!) + addEncoded(encode(value, encodeNextWith)!!) } /** @@ -43,7 +48,7 @@ public class FieldValuesDSL internal constructor() { * @param value the value [T] to add */ public fun addWithStrategy(strategy: SerializationStrategy, value: T) { - addEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!) + addEncoded(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!) } @PublishedApi diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt index 7fca11765..a1280c6fb 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt @@ -23,20 +23,25 @@ public class FieldsAndValuesUpdateDSL internal constructor() { internal val fieldAndValues: MutableList = mutableListOf() + @PublishedApi + internal var encodeNextWith: EncodeSettings.Builder.() -> Unit = { + encodeDefaults = true + } + /** - * The [EncodeSettings.Builder] to apply to the next values added to this update. + * Sets the [EncodeSettings.Builder] to apply to the next values added to this update. * Updating this value will only influence the encoding of values not yet added to the update. * This allows for custom encoding per update, e.g. * * ``` - * buildSettings = { encodeDefaults = true } + * encodeNextWith { encodeDefaults = true } * "path" to ClassWithDefaults() - * buildSettings = { encodeDefaults = false } + * encodeNextWith { encodeDefaults = false } * "otherPath" to ClassWithDefaults() * ``` */ - public var buildSettings: EncodeSettings.Builder.() -> Unit = { - encodeDefaults = true + public fun encodeNextWith(builder: EncodeSettings.Builder.() -> Unit) { + encodeNextWith = builder } /** @@ -45,7 +50,7 @@ public class FieldsAndValuesUpdateDSL internal constructor() { * @param value the value [T] to update to */ public inline infix fun String.to(value: T) { - toEncoded(encode(value, buildSettings)) + toEncoded(encode(value, encodeNextWith)) } /** @@ -54,7 +59,7 @@ public class FieldsAndValuesUpdateDSL internal constructor() { * @param value the value [T] to update to */ public inline infix fun FieldPath.to(value: T) { - toEncoded(encode(value, buildSettings)) + toEncoded(encode(value, encodeNextWith)) } /** @@ -64,7 +69,7 @@ public class FieldsAndValuesUpdateDSL internal constructor() { * @param value the value [T] to update to */ public fun String.to(strategy: SerializationStrategy, value: T) { - toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)) + toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)) } /** @@ -74,7 +79,7 @@ public class FieldsAndValuesUpdateDSL internal constructor() { * @param value the value [T] to update to */ public fun FieldPath.to(strategy: SerializationStrategy, value: T) { - toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)) + toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)) } @PublishedApi diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt index 3f5785c9f..ee9004fda 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt @@ -41,192 +41,209 @@ public sealed class Filter { public class FilterBuilder internal constructor() { - public var buildSettings: EncodeSettings.Builder.() -> Unit = { + @PublishedApi + internal var encodeNextWith: EncodeSettings.Builder.() -> Unit = { encodeDefaults = true } + /** + * Sets the [EncodeSettings.Builder] to apply to the next [WhereConstraint] added. + * Updating this value will only influence the encoding of [WhereConstraint] not yet added to the update. + * This allows for custom encoding per value, e.g. + * + * ``` + * encodeNextWith { encodeDefaults = true } + * "path" equalTo value + * encodeNextWith { encodeDefaults = false } + * "otherPath" equalTo otherValue + * ``` + */ + public fun encodeNextWith(builder: EncodeSettings.Builder.() -> Unit) { + encodeNextWith = builder + } + public val String.isNull: Filter.WithConstraint get() = Filter.Field(this, WhereConstraint.EqualTo(null)) public inline infix fun String.equalTo(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.EqualTo(encode(value, buildSettings)), + WhereConstraint.EqualTo(encode(value, encodeNextWith)), ) public fun String.equalTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.EqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)), + WhereConstraint.EqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)), ) public val FieldPath.isNull: Filter.WithConstraint get() = Filter.Path(this, WhereConstraint.EqualTo(null)) public inline infix fun FieldPath.equalTo(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.EqualTo(encode(value, buildSettings)), + WhereConstraint.EqualTo(encode(value, encodeNextWith)), ) public fun FieldPath.equalTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.EqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)), + WhereConstraint.EqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)), ) public val String.isNotNull: Filter.WithConstraint get() = Filter.Field(this, WhereConstraint.NotEqualTo(null)) public inline infix fun String.notEqualTo(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.NotEqualTo(encode(value, buildSettings)), + WhereConstraint.NotEqualTo(encode(value, encodeNextWith)), ) public fun String.notEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.NotEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)), + WhereConstraint.NotEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)), ) public val FieldPath.isNotNull: Filter.WithConstraint get() = Filter.Path(this, WhereConstraint.NotEqualTo(null)) public inline infix fun FieldPath.notEqualTo(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.NotEqualTo(encode(value, buildSettings)), + WhereConstraint.NotEqualTo(encode(value, encodeNextWith)), ) public fun FieldPath.notEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.NotEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)), + WhereConstraint.NotEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)), ) public inline infix fun String.lessThan(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.LessThan(encode(value, buildSettings)!!), + WhereConstraint.LessThan(encode(value, encodeNextWith)!!), ) public fun String.lessThan(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.LessThan(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.LessThan(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun FieldPath.lessThan(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.LessThan(encode(value, buildSettings)!!), + WhereConstraint.LessThan(encode(value, encodeNextWith)!!), ) public fun FieldPath.lessThan(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.LessThan(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.LessThan(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun String.greaterThan(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.GreaterThan(encode(value, buildSettings)!!), + WhereConstraint.GreaterThan(encode(value, encodeNextWith)!!), ) public fun String.greaterThan(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.GreaterThan(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.GreaterThan(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun FieldPath.greaterThan(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.GreaterThan(encode(value, buildSettings)!!), + WhereConstraint.GreaterThan(encode(value, encodeNextWith)!!), ) public fun FieldPath.greaterThan(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.GreaterThan(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.GreaterThan(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun String.lessThanOrEqualTo(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.LessThanOrEqualTo(encode(value, buildSettings)!!), + WhereConstraint.LessThanOrEqualTo(encode(value, encodeNextWith)!!), ) public fun String.lessThanOrEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.LessThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.LessThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun FieldPath.lessThanOrEqualTo(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.LessThanOrEqualTo(encode(value, buildSettings)!!), + WhereConstraint.LessThanOrEqualTo(encode(value, encodeNextWith)!!), ) public fun FieldPath.lessThanOrEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.LessThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.LessThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun String.greaterThanOrEqualTo(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.GreaterThanOrEqualTo(encode(value, buildSettings)!!), + WhereConstraint.GreaterThanOrEqualTo(encode(value, encodeNextWith)!!), ) public fun String.greaterThanOrEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.GreaterThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.GreaterThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun FieldPath.greaterThanOrEqualTo(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.GreaterThanOrEqualTo(encode(value, buildSettings)!!), + WhereConstraint.GreaterThanOrEqualTo(encode(value, encodeNextWith)!!), ) public fun FieldPath.greaterThanOrEqualTo(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.GreaterThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.GreaterThanOrEqualTo(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun String.contains(value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.ArrayContains(encode(value, buildSettings)!!), + WhereConstraint.ArrayContains(encode(value, encodeNextWith)!!), ) public fun String.contains(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.ArrayContains(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.ArrayContains(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun FieldPath.contains(value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.ArrayContains(encode(value, buildSettings)!!), + WhereConstraint.ArrayContains(encode(value, encodeNextWith)!!), ) public fun FieldPath.contains(strategy: SerializationStrategy, value: T): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.ArrayContains(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!), + WhereConstraint.ArrayContains(dev.gitlive.firebase.internal.encode(strategy, value, encodeNextWith)!!), ) public inline infix fun String.containsAny(values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.ArrayContainsAny(values.map { encode(it, buildSettings)!! }), + WhereConstraint.ArrayContainsAny(values.map { encode(it, encodeNextWith)!! }), ) public fun String.containsAny(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.ArrayContainsAny(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.ArrayContainsAny(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public inline infix fun FieldPath.containsAny(values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.ArrayContainsAny(values.map { encode(it, buildSettings)!! }), + WhereConstraint.ArrayContainsAny(values.map { encode(it, encodeNextWith)!! }), ) public fun FieldPath.containsAny(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.ArrayContainsAny(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.ArrayContainsAny(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public inline infix fun String.inArray(values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.InArray(values.map { encode(it, buildSettings)!! }), + WhereConstraint.InArray(values.map { encode(it, encodeNextWith)!! }), ) public fun String.inArray(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.InArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.InArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public inline infix fun FieldPath.inArray(values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.InArray(values.map { encode(it, buildSettings)!! }), + WhereConstraint.InArray(values.map { encode(it, encodeNextWith)!! }), ) public fun FieldPath.inArray(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.InArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.InArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public inline infix fun String.notInArray(values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.NotInArray(values.map { encode(it, buildSettings)!! }), + WhereConstraint.NotInArray(values.map { encode(it, encodeNextWith)!! }), ) public fun String.notInArray(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Field( this, - WhereConstraint.NotInArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.NotInArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public inline infix fun FieldPath.notInArray(values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.NotInArray(values.map { encode(it, buildSettings)!! }), + WhereConstraint.NotInArray(values.map { encode(it, encodeNextWith)!! }), ) public fun FieldPath.notInArray(strategy: SerializationStrategy, values: List): Filter.WithConstraint = Filter.Path( this, - WhereConstraint.NotInArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, buildSettings)!! }), + WhereConstraint.NotInArray(values.map { dev.gitlive.firebase.internal.encode(strategy, it, encodeNextWith)!! }), ) public infix fun Filter.and(right: Filter): Filter.And { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index c5a9b493e..b030660cf 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -200,7 +200,7 @@ public data class Transaction internal constructor(internal val nativeWrapper: N updateFields( documentRef, ) { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (field, value) -> field to value } @@ -215,7 +215,7 @@ public data class Transaction internal constructor(internal val nativeWrapper: N updateFields( documentRef, ) { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (field, value) -> field to value } @@ -262,7 +262,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue public fun startAfter(vararg fieldValues: Any?): Query = startAfter(*fieldValues) {} public fun startAfter(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query = startAfterFieldValues { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldValues.forEach { add(it) } @@ -280,7 +280,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue public fun startAt(vararg fieldValues: Any?): Query = startAt(*fieldValues) {} public fun startAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query = startAtFieldValues { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldValues.forEach { add(it) } @@ -298,7 +298,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue public fun endBefore(vararg fieldValues: Any?): Query = endBefore(*fieldValues) {} public fun endBefore(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query = endBeforeFieldValues { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldValues.forEach { add(it) } @@ -316,7 +316,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue public fun endAt(vararg fieldValues: Any?): Query = endAt(*fieldValues) {} public fun endAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query = endAtFieldValues { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldValues.forEach { add(it) } @@ -463,7 +463,7 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na updateFields( documentRef, ) { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (field, value) -> field to value } @@ -478,7 +478,7 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na updateFields( documentRef, ) { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (path, value) -> path to value } @@ -645,7 +645,7 @@ public data class DocumentReference internal constructor(internal val native: Na @JvmName("updateFields") public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Unit = updateFields { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (field, value) -> field to value } @@ -658,7 +658,7 @@ public data class DocumentReference internal constructor(internal val native: Na @JvmName("updateFieldPaths") public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Unit = updateFields { - this.buildSettings = buildSettings + encodeNextWith(buildSettings) fieldsAndValues.forEach { (fieldPath, value) -> fieldPath to value }