From 413539e7f7364774d292f8a6332bd4e9a9d5bd14 Mon Sep 17 00:00:00 2001 From: Julien Buret Date: Fri, 17 May 2019 16:38:41 +0200 Subject: [PATCH] fixes #137 Typed query isn't type-safe --- .../test/kotlin/org/litote/kmongo/PathTest.kt | 3 +- .../kotlin/kotlin/internal/Annotations.kt | 21 +++++++ .../main/kotlin/org/litote/kmongo/Filters.kt | 42 +++++++++----- .../kotlin/org/litote/kmongo/Properties.kt | 4 +- .../main/kotlin/org/litote/kmongo/Updates.kt | 55 ++++++++++++------- .../litote/kmongo/property/KPropertyPath.kt | 6 +- .../kotlin/org/litote/kmongo/FiltersTest.kt | 45 +++++++++++++++ .../kotlin/org/litote/kmongo/UpdatesTest.kt | 33 +++++++++++ 8 files changed, 169 insertions(+), 40 deletions(-) create mode 100644 kmongo-property/src/main/kotlin/kotlin/internal/Annotations.kt create mode 100644 kmongo-property/src/test/kotlin/org/litote/kmongo/FiltersTest.kt create mode 100644 kmongo-property/src/test/kotlin/org/litote/kmongo/UpdatesTest.kt diff --git a/kmongo-annotation-processor/src/test/kotlin/org/litote/kmongo/PathTest.kt b/kmongo-annotation-processor/src/test/kotlin/org/litote/kmongo/PathTest.kt index d5398c3c..b2485c23 100644 --- a/kmongo-annotation-processor/src/test/kotlin/org/litote/kmongo/PathTest.kt +++ b/kmongo-annotation-processor/src/test/kotlin/org/litote/kmongo/PathTest.kt @@ -17,6 +17,7 @@ package org.litote.kmongo import org.junit.Test +import org.litote.kmongo.model.SimpleReferenced2Data import org.litote.kmongo.model.SubData2_ import org.litote.kmongo.model.TestData_ import org.litote.kmongo.model.other.SimpleReferencedData @@ -73,7 +74,7 @@ class PathTest { //check compilation if (false) - (TestData_.Map2.keyProjection(Locale.ENGLISH) eq SimpleReferencedData()).json + (TestData_.Map2.keyProjection(Locale.ENGLISH) eq SimpleReferenced2Data()).json assertEquals( "set.$.labels.zh_CN", diff --git a/kmongo-property/src/main/kotlin/kotlin/internal/Annotations.kt b/kmongo-property/src/main/kotlin/kotlin/internal/Annotations.kt new file mode 100644 index 00000000..871b392e --- /dev/null +++ b/kmongo-property/src/main/kotlin/kotlin/internal/Annotations.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017/2019 Litote + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.internal + +@Target(AnnotationTarget.TYPE_PARAMETER) +@Retention(AnnotationRetention.BINARY) +internal annotation class OnlyInputTypes \ No newline at end of file diff --git a/kmongo-property/src/main/kotlin/org/litote/kmongo/Filters.kt b/kmongo-property/src/main/kotlin/org/litote/kmongo/Filters.kt index 70f743ee..6ae8ed97 100644 --- a/kmongo-property/src/main/kotlin/org/litote/kmongo/Filters.kt +++ b/kmongo-property/src/main/kotlin/org/litote/kmongo/Filters.kt @@ -25,6 +25,7 @@ import org.bson.BsonType import org.bson.Document import org.bson.conversions.Bson import java.util.regex.Pattern +import kotlin.internal.OnlyInputTypes import kotlin.reflect.KProperty /** @@ -34,9 +35,9 @@ import kotlin.reflect.KProperty * @param value the value * @param the value type * @return the filter - * @mongodb.driver.manual reference/operator/query/eq $eq + * @mongodb.driveDr.manual reference/operator/query/eq $eq */ -infix fun KProperty.eq(value: T): Bson = Filters.eq(path(), value) +infix fun <@OnlyInputTypes T, V : T> KProperty.eq(value: V): Bson = Filters.eq(path(), value) /** * Creates a filter that matches all documents where the value of the property contains the specified value. Note that this doesn't @@ -52,7 +53,7 @@ infix fun KProperty.eq(value: T): Bson = Filters.eq(path(), value) * @return the filter * @mongodb.driver.manual reference/operator/query/eq/#op._S_eq */ -infix fun KProperty?>.contains(value: T): Bson = Filters.eq(path(), value) +infix fun <@OnlyInputTypes T> KProperty?>.contains(value: T): Bson = Filters.eq(path(), value) /** * Creates a filter that matches all documents where the value of the field name does not equal the specified value. @@ -62,7 +63,7 @@ infix fun KProperty?>.contains(value: T): Bson = Filters.eq(pa * @return the filter * @mongodb.driver.manual reference/operator/query/ne $ne */ -infix fun KProperty.ne(value: T): Bson = Filters.ne(path(), value) +infix fun <@OnlyInputTypes T> KProperty.ne(value: T): Bson = Filters.ne(path(), value) /** * Creates a filter that matches all documents where the value of the given property is less than the specified value. @@ -72,7 +73,7 @@ infix fun KProperty.ne(value: T): Bson = Filters.ne(path(), value) * @return the filter * @mongodb.driver.manual reference/operator/query/lt $lt */ -infix fun KProperty.lt(item: T): Bson = Filters.lt(path(), item) +infix fun <@OnlyInputTypes T> KProperty.lt(item: T): Bson = Filters.lt(path(), item) /** * Creates a filter that matches all documents where the value of the given property is greater than the specified value. @@ -82,7 +83,7 @@ infix fun KProperty.lt(item: T): Bson = Filters.lt(path(), item) * @return the filter * @mongodb.driver.manual reference/operator/query/gt $gt */ -infix fun KProperty.gt(value: T): Bson = Filters.gt(path(), value) +infix fun <@OnlyInputTypes T> KProperty.gt(value: T): Bson = Filters.gt(path(), value) /** * Creates a filter that matches all documents where the value of the given property is less than or equal to the specified value. @@ -92,7 +93,7 @@ infix fun KProperty.gt(value: T): Bson = Filters.gt(path(), value) * @return the filter * @mongodb.driver.manual reference/operator/query/lte $lte */ -infix fun KProperty.lte(value: T): Bson = Filters.lte(path(), value) +infix fun <@OnlyInputTypes T> KProperty.lte(value: T): Bson = Filters.lte(path(), value) /** * Creates a filter that matches all documents where the value of the given property is greater than or equal to the specified value. @@ -102,7 +103,7 @@ infix fun KProperty.lte(value: T): Bson = Filters.lte(path(), value) * @return the filter * @mongodb.driver.manual reference/operator/query/gte $gte */ -infix fun KProperty.gte(value: T): Bson = Filters.gte(path(), value) +infix fun <@OnlyInputTypes T> KProperty.gte(value: T): Bson = Filters.gte(path(), value) /** * Creates a filter that matches all documents where the value of a property equals any value in the list of specified values. @@ -112,7 +113,7 @@ infix fun KProperty.gte(value: T): Bson = Filters.gte(path(), value) * @return the filter * @mongodb.driver.manual reference/operator/query/in $in */ -infix fun KProperty.`in`(values: Iterable): Bson = Filters.`in`(path(), values) +infix fun <@OnlyInputTypes T> KProperty.`in`(values: Iterable): Bson = Filters.`in`(path(), values) /** * Creates a filter that matches all documents where the value of a property equals any value in the list of specified values. @@ -122,7 +123,8 @@ infix fun KProperty.`in`(values: Iterable): Bson = Filters.`in`(path() * @return the filter * @mongodb.driver.manual reference/operator/query/in $in */ -infix fun KProperty.contains(values: Iterable): Bson = `in`(values) +@JvmName("inArray") +infix fun <@OnlyInputTypes T> KProperty?>.`in`(values: Iterable): Bson = Filters.`in`(path(), values) /** * Creates a filter that matches all documents where the value of a property does not equal any of the specified values or does not exist. @@ -132,7 +134,19 @@ infix fun KProperty.contains(values: Iterable): Bson = `in`(values) * @return the filter * @mongodb.driver.manual reference/operator/query/nin $nin */ -infix fun KProperty.nin(values: Iterable): Bson = Filters.nin(path(), values) +infix fun <@OnlyInputTypes T> KProperty.nin(values: Iterable): Bson = Filters.nin(path(), values) + +/** + * Creates a filter that matches all documents where the value of a property does not equal any of the specified values or does not exist. + * + * @param values the list of values + * @param the value type + * @return the filter + * @mongodb.driver.manual reference/operator/query/nin $nin + */ +@JvmName("ninArray") +infix fun <@OnlyInputTypes T> KProperty?>.nin(values: Iterable): Bson = Filters.nin(path(), values) + /** * Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" @@ -355,7 +369,7 @@ fun expr(expression: TExpression): Bson = Filters.expr(expression) * @return the filter * @mongodb.driver.manual reference/operator/query/all $all */ -infix fun KProperty.all(values: Iterable): Bson = Filters.all(path(), values) +infix fun <@OnlyInputTypes T> KProperty?>.all(values: Iterable): Bson = Filters.all(path(), values) /** * Creates a filter that matches all documents where the value of a property is an array that contains all the specified values. @@ -365,7 +379,7 @@ infix fun KProperty.all(values: Iterable): Bson = Filters.all(path(), * @return the filter * @mongodb.driver.manual reference/operator/query/all $all */ -fun KProperty.all(vararg values: T): Bson = Filters.all(path(), *values) +fun <@OnlyInputTypes T> KProperty?>.all(vararg values: T): Bson = Filters.all(path(), *values) /** * Creates a filter that matches all documents containing a property that is an array where at least one member of the array matches the @@ -375,7 +389,7 @@ fun KProperty.all(vararg values: T): Bson = Filters.all(path(), *values) * @return the filter * @mongodb.driver.manual reference/operator/query/elemMatch $elemMatch */ -infix fun KProperty>.elemMatch(filter: Bson): Bson = Filters.elemMatch(path(), filter) +infix fun KProperty>.elemMatch(filter: Bson): Bson = Filters.elemMatch(path(), filter) /** * Creates a filter that matches all documents where the value of a property is an array of the specified size. diff --git a/kmongo-property/src/main/kotlin/org/litote/kmongo/Properties.kt b/kmongo-property/src/main/kotlin/org/litote/kmongo/Properties.kt index ababa0ee..666d5b48 100644 --- a/kmongo-property/src/main/kotlin/org/litote/kmongo/Properties.kt +++ b/kmongo-property/src/main/kotlin/org/litote/kmongo/Properties.kt @@ -33,7 +33,7 @@ operator fun KProperty1.div(p2: KProperty1): KPro * Returns a collection composed property. For example Friend.addresses / Address.postalCode = "addresses.postalCode". */ @JvmName("divCol") -operator fun KProperty1?>.div(p2: KProperty1): KProperty1 = +operator fun KProperty1?>.div(p2: KProperty1): KProperty1 = KPropertyPath(this, p2) /** @@ -52,7 +52,7 @@ fun KProperty.path(): String = /** * Returns a collection property. */ -val KProperty1>.colProperty: KCollectionSimplePropertyPath +val KProperty1>.colProperty: KCollectionSimplePropertyPath get() = KCollectionSimplePropertyPath(null, this) diff --git a/kmongo-property/src/main/kotlin/org/litote/kmongo/Updates.kt b/kmongo-property/src/main/kotlin/org/litote/kmongo/Updates.kt index bf487fbc..d47a3052 100644 --- a/kmongo-property/src/main/kotlin/org/litote/kmongo/Updates.kt +++ b/kmongo-property/src/main/kotlin/org/litote/kmongo/Updates.kt @@ -28,6 +28,7 @@ import com.mongodb.client.model.UpdateOneModel import com.mongodb.client.model.UpdateOptions import com.mongodb.client.model.Updates import org.bson.conversions.Bson +import kotlin.internal.OnlyInputTypes import kotlin.reflect.KProperty /** @@ -36,7 +37,7 @@ import kotlin.reflect.KProperty * @param the value to set. * @return the SetTo instance. */ -infix fun KProperty.setTo(value: T): SetTo = SetTo(this, value) +infix fun <@OnlyInputTypes T> KProperty.setTo(value: T): SetTo = SetTo(this, value) /** * Combine a list of updates into a single update. @@ -63,7 +64,21 @@ fun combine(updates: List): Bson = Updates.combine(updates) * @return the update * @mongodb.driver.manual reference/operator/update/set/ $set */ -fun set(property: KProperty, value: T): Bson = Updates.set(property.path(), value) +@Deprecated("use setValue") +fun <@OnlyInputTypes T> set(property: KProperty, value: T): Bson = Updates.set(property.path(), value) + + +/** + * Creates an update that sets the value of the property to the given value. + * + * @param property the property + * @param value the value + * @param the value type + * @return the update + * @mongodb.driver.manual reference/operator/update/set/ $set + */ +fun <@OnlyInputTypes T> setValue(property: KProperty, value: T): Bson = Updates.set(property.path(), value) + /** * Creates an update that sets the values of the properties to the specified values. @@ -95,7 +110,7 @@ fun unset(property: KProperty): Bson = Updates.unset(property.path()) * @mongodb.driver.manual reference/operator/update/setOnInsert/ $setOnInsert * @see UpdateOptions#upsert(boolean) */ -fun setOnInsert(property: KProperty, value: T): Bson = Updates.setOnInsert(property.path(), value) +fun <@OnlyInputTypes T> setOnInsert(property: KProperty, value: T): Bson = Updates.setOnInsert(property.path(), value) /** * Creates an update that renames a field. @@ -105,7 +120,7 @@ fun setOnInsert(property: KProperty, value: T): Bson = Updates.setOnInser * @return the update * @mongodb.driver.manual reference/operator/update/rename/ $rename */ -fun rename(property: KProperty, newProperty: KProperty): Bson = +fun <@OnlyInputTypes T> rename(property: KProperty, newProperty: KProperty): Bson = Updates.rename(property.path(), newProperty.path()) /** @@ -116,7 +131,7 @@ fun rename(property: KProperty, newProperty: KProperty): Bson = * @return the update * @mongodb.driver.manual reference/operator/update/inc/ $inc */ -fun inc(property: KProperty, number: Number): Bson = Updates.inc(property.path(), number) +fun inc(property: KProperty, number: Number): Bson = Updates.inc(property.path(), number) /** * Creates an update that multiplies the value of the property by the given number. @@ -126,7 +141,7 @@ fun inc(property: KProperty, number: Number): Bson = Updates.inc(property * @return the update * @mongodb.driver.manual reference/operator/update/mul/ $mul */ -fun mul(property: KProperty, number: Number): Bson = Updates.mul(property.path(), number) +fun mul(property: KProperty, number: Number): Bson = Updates.mul(property.path(), number) /** * Creates an update that sets the value of the property if the given value is less than the current value of the @@ -138,7 +153,7 @@ fun mul(property: KProperty, number: Number): Bson = Updates.mul(property * @return the update * @mongodb.driver.manual reference/operator/update/min/ $min */ -fun min(property: KProperty, value: T): Bson = Updates.min(property.path(), value) +fun <@OnlyInputTypes T> min(property: KProperty, value: T): Bson = Updates.min(property.path(), value) /** * Creates an update that sets the value of the property if the given value is greater than the current value of the @@ -150,7 +165,7 @@ fun min(property: KProperty, value: T): Bson = Updates.min(property.path( * @return the update * @mongodb.driver.manual reference/operator/update/min/ $min */ -fun max(property: KProperty, value: T): Bson = Updates.max(property.path(), value) +fun <@OnlyInputTypes T> max(property: KProperty, value: T): Bson = Updates.max(property.path(), value) /** * Creates an update that sets the value of the property to the current date as a BSON date. @@ -182,7 +197,7 @@ fun currentTimestamp(property: KProperty): Bson = Updates.currentTimestam * @return the update * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet */ -fun addToSet(property: KProperty, value: T): Bson = Updates.addToSet(property.path(), value) +fun <@OnlyInputTypes T> addToSet(property: KProperty?>, value: T): Bson = Updates.addToSet(property.path(), value) /** * Creates an update that adds each of the given values to the array value of the property, unless the value is @@ -194,7 +209,7 @@ fun addToSet(property: KProperty, value: T): Bson = Updates.addToSet(prop * @return the update * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet */ -fun addEachToSet(property: KProperty, values: List): Bson = Updates.addEachToSet(property.path(), values) +fun <@OnlyInputTypes T> addEachToSet(property: KProperty?>, values: List): Bson = Updates.addEachToSet(property.path(), values) /** * Creates an update that adds the given value to the array value of the property. @@ -205,7 +220,7 @@ fun addEachToSet(property: KProperty, values: List): Bson = Updates.ad * @return the update * @mongodb.driver.manual reference/operator/update/push/ $push */ -fun push(property: KProperty, value: T): Bson = Updates.push(property.path(), value) +fun <@OnlyInputTypes T> push(property: KProperty?>, value: T): Bson = Updates.push(property.path(), value) /** * Creates an update that adds each of the given values to the array value of the property, applying the given @@ -218,7 +233,7 @@ fun push(property: KProperty, value: T): Bson = Updates.push(property.pat * @return the update * @mongodb.driver.manual reference/operator/update/push/ $push */ -fun pushEach(property: KProperty, values: List, options: PushOptions = PushOptions()): Bson = +fun <@OnlyInputTypes T> pushEach(property: KProperty?>, values: List, options: PushOptions = PushOptions()): Bson = Updates.pushEach(property.path(), values, options) /** @@ -230,7 +245,7 @@ fun pushEach(property: KProperty, values: List, options: PushOptions * @return the update * @mongodb.driver.manual reference/operator/update/pull/ $pull */ -fun pull(property: KProperty?>, value: T?): Bson = Updates.pull(property.path(), value) +fun <@OnlyInputTypes T> pull(property: KProperty?>, value: T?): Bson = Updates.pull(property.path(), value) /** * Creates an update that removes all instances of the given value from the array value of the property. @@ -260,7 +275,7 @@ fun pullByFilter(filter: Bson): Bson = Updates.pullByFilter(filter) * @return the update * @mongodb.driver.manual reference/operator/update/pull/ $pull */ -fun pullAll(property: KProperty, values: List?): Bson = +fun <@OnlyInputTypes T> pullAll(property: KProperty?>, values: List?): Bson = Updates.pullAll(property.path(), values ?: emptyList()) /** @@ -288,7 +303,7 @@ fun popLast(property: KProperty): Bson = Updates.popLast(property.path()) * @param value the value * @return the update */ -fun bitwiseAnd(property: KProperty, value: Int): Bson = Updates.bitwiseAnd(property.path(), value) +fun bitwiseAnd(property: KProperty, value: Int): Bson = Updates.bitwiseAnd(property.path(), value) /** * Creates an update that performs a bitwise and between the given long value and the integral value of the property. @@ -298,7 +313,7 @@ fun bitwiseAnd(property: KProperty, value: Int): Bson = Updates.bitwiseAn * @return the update * @mongodb.driver.manual reference/operator/update/bit/ $bit */ -fun bitwiseAnd(property: KProperty, value: Long): Bson = Updates.bitwiseAnd(property.path(), value) +fun bitwiseAnd(property: KProperty, value: Long): Bson = Updates.bitwiseAnd(property.path(), value) /** * Creates an update that performs a bitwise or between the given integer value and the integral value of the property. @@ -308,7 +323,7 @@ fun bitwiseAnd(property: KProperty, value: Long): Bson = Updates.bitwiseA * @return the update * @mongodb.driver.manual reference/operator/update/bit/ $bit */ -fun bitwiseOr(property: KProperty, value: Int): Bson = Updates.bitwiseOr(property.path(), value) +fun bitwiseOr(property: KProperty, value: Int): Bson = Updates.bitwiseOr(property.path(), value) /** * Creates an update that performs a bitwise or between the given long value and the integral value of the property. @@ -318,7 +333,7 @@ fun bitwiseOr(property: KProperty, value: Int): Bson = Updates.bitwiseOr( * @return the update * @mongodb.driver.manual reference/operator/update/bit/ $bit */ -fun bitwiseOr(property: KProperty, value: Long): Bson = Updates.bitwiseOr(property.path(), value) +fun bitwiseOr(property: KProperty, value: Long): Bson = Updates.bitwiseOr(property.path(), value) /** * Creates an update that performs a bitwise xor between the given integer value and the integral value of the property. @@ -327,7 +342,7 @@ fun bitwiseOr(property: KProperty, value: Long): Bson = Updates.bitwiseOr * @param value the value * @return the update */ -fun bitwiseXor(property: KProperty, value: Int): Bson = Updates.bitwiseXor(property.path(), value) +fun bitwiseXor(property: KProperty, value: Int): Bson = Updates.bitwiseXor(property.path(), value) /** * Creates an update that performs a bitwise xor between the given long value and the integral value of the property. @@ -336,7 +351,7 @@ fun bitwiseXor(property: KProperty, value: Int): Bson = Updates.bitwiseXo * @param value the value * @return the update */ -fun bitwiseXor(property: KProperty, value: Long): Bson = Updates.bitwiseXor(property.path(), value) +fun bitwiseXor(property: KProperty, value: Long): Bson = Updates.bitwiseXor(property.path(), value) /** * Creates an InsertOneModel. diff --git a/kmongo-property/src/main/kotlin/org/litote/kmongo/property/KPropertyPath.kt b/kmongo-property/src/main/kotlin/org/litote/kmongo/property/KPropertyPath.kt index 61efa52b..f00bafe8 100644 --- a/kmongo-property/src/main/kotlin/org/litote/kmongo/property/KPropertyPath.kt +++ b/kmongo-property/src/main/kotlin/org/litote/kmongo/property/KPropertyPath.kt @@ -140,8 +140,8 @@ open class KPropertyPath( */ open class KCollectionPropertyPath>( previous: KPropertyPath?, - property: KProperty1<*, Collection?> -) : KPropertyPath?>(previous, property) { + property: KProperty1<*, Iterable?> +) : KPropertyPath?>(previous, property) { /** * To be overridden to returns the right type. @@ -178,7 +178,7 @@ open class KCollectionPropertyPath>( */ class KCollectionSimplePropertyPath( previous: KPropertyPath?, - property: KProperty1<*, Collection?> + property: KProperty1<*, Iterable?> ) : KCollectionPropertyPath>(previous, property) /** diff --git a/kmongo-property/src/test/kotlin/org/litote/kmongo/FiltersTest.kt b/kmongo-property/src/test/kotlin/org/litote/kmongo/FiltersTest.kt new file mode 100644 index 00000000..153cd9ef --- /dev/null +++ b/kmongo-property/src/test/kotlin/org/litote/kmongo/FiltersTest.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017/2019 Litote + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.litote.kmongo + +import org.junit.Test + +/** + * + */ +class FiltersTest { + + class T(val s: List) + + @Test + fun `all works with Iterable sub interface`() { + //check this compile + T::s all setOf("test") + } + + @Test + fun `in works with a collection property`() { + //check this compile + T::s `in` setOf("test") + } + + @Test + fun `nin works with a collection property`() { + //check this compile + T::s nin setOf("test") + } +} \ No newline at end of file diff --git a/kmongo-property/src/test/kotlin/org/litote/kmongo/UpdatesTest.kt b/kmongo-property/src/test/kotlin/org/litote/kmongo/UpdatesTest.kt new file mode 100644 index 00000000..fb403cde --- /dev/null +++ b/kmongo-property/src/test/kotlin/org/litote/kmongo/UpdatesTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017/2019 Litote + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.litote.kmongo + +import org.junit.Test + +/** + * + */ +class UpdatesTest { + + class T(val s: List) + + @Test + fun `addEachToSet works with Iterable sub interface`() { + //check this compile + T::s all setOf("test") + } +} \ No newline at end of file