Compare commits
16 Commits
2.1.11.REL
...
2.1.13.REL
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e74fe05abd | ||
|
|
d579254fbc | ||
|
|
71c8e4cc02 | ||
|
|
a087c7d17c | ||
|
|
90cec275a6 | ||
|
|
e4eefe577d | ||
|
|
b57a6612f6 | ||
|
|
62b2d54e0d | ||
|
|
aff823da57 | ||
|
|
d45b630724 | ||
|
|
fc8c97aeb0 | ||
|
|
004e7f01b2 | ||
|
|
5c80ee0087 | ||
|
|
adb9dc29a2 | ||
|
|
6eb6feadbb | ||
|
|
166aab39c4 |
6
pom.xml
6
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Data MongoDB</name>
|
||||
@@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -27,7 +27,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>2.1.11.RELEASE</springdata.commons>
|
||||
<springdata.commons>2.1.13.RELEASE</springdata.commons>
|
||||
<mongo>3.8.2</mongo>
|
||||
<mongo.reactivestreams>1.9.2</mongo.reactivestreams>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- reactive -->
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.1.11.RELEASE</version>
|
||||
<version>2.1.13.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.springframework.data.mongodb.util.BsonUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -107,8 +108,8 @@ public class IndexInfo {
|
||||
boolean sparse = sourceDocument.containsKey("sparse") ? (Boolean) sourceDocument.get("sparse") : false;
|
||||
String language = sourceDocument.containsKey("default_language") ? (String) sourceDocument.get("default_language")
|
||||
: "";
|
||||
String partialFilter = sourceDocument.containsKey("partialFilterExpression")
|
||||
? ((Document) sourceDocument.get("partialFilterExpression")).toJson() : null;
|
||||
|
||||
String partialFilter = extractPartialFilterString(sourceDocument);
|
||||
|
||||
IndexInfo info = new IndexInfo(indexFields, name, unique, sparse, language);
|
||||
info.partialFilterExpression = partialFilter;
|
||||
@@ -116,6 +117,21 @@ public class IndexInfo {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sourceDocument
|
||||
* @return the {@link String} representation of the partial filter {@link Document}.
|
||||
* @since 2.1.11
|
||||
*/
|
||||
@Nullable
|
||||
private static String extractPartialFilterString(Document sourceDocument) {
|
||||
|
||||
if (!sourceDocument.containsKey("partialFilterExpression")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return BsonUtils.toJson(sourceDocument.get("partialFilterExpression", Document.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the individual index fields of the index.
|
||||
*
|
||||
|
||||
@@ -15,17 +15,26 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.bson.BsonValue;
|
||||
import org.bson.Document;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.bson.json.JsonParseException;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.DBRef;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@@ -104,4 +113,80 @@ public class BsonUtils {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given {@link Document} as Json applying default codecs if necessary.
|
||||
*
|
||||
* @param source
|
||||
* @return
|
||||
* @since 2.1.12
|
||||
*/
|
||||
@Nullable
|
||||
public static String toJson(@Nullable Document source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return source.toJson();
|
||||
} catch (Exception e) {
|
||||
return toJson((Object) source);
|
||||
}
|
||||
}
|
||||
|
||||
private static String toJson(@Nullable Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return value instanceof Document
|
||||
? ((Document) value).toJson(MongoClientSettings.getDefaultCodecRegistry().get(Document.class))
|
||||
: serializeValue(value);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if (value instanceof Collection) {
|
||||
return toString((Collection<?>) value);
|
||||
} else if (value instanceof Map) {
|
||||
return toString((Map<?, ?>) value);
|
||||
} else if (ObjectUtils.isArray(value)) {
|
||||
return toString(Arrays.asList(ObjectUtils.toObjectArray(value)));
|
||||
}
|
||||
|
||||
throw e instanceof JsonParseException ? (JsonParseException) e : new JsonParseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String serializeValue(@Nullable Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
String documentJson = new Document("toBeEncoded", value).toJson();
|
||||
return documentJson.substring(documentJson.indexOf(':') + 1, documentJson.length() - 1).trim();
|
||||
}
|
||||
|
||||
private static String toString(Map<?, ?> source) {
|
||||
|
||||
return iterableToDelimitedString(source.entrySet(), "{ ", " }",
|
||||
entry -> String.format("\"%s\" : %s", entry.getKey(), toJson(entry.getValue())));
|
||||
}
|
||||
|
||||
private static String toString(Collection<?> source) {
|
||||
return iterableToDelimitedString(source, "[ ", " ]", BsonUtils::toJson);
|
||||
}
|
||||
|
||||
private static <T> String iterableToDelimitedString(Iterable<T> source, String prefix, String suffix,
|
||||
Converter<? super T, String> transformer) {
|
||||
|
||||
StringJoiner joiner = new StringJoiner(", ", prefix, suffix);
|
||||
|
||||
StreamSupport.stream(source.spliterator(), false).map(transformer::convert).forEach(joiner::add);
|
||||
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ fun <T : Any> ExecutableFindOperation.DistinctWithProjection.asType(resultType:
|
||||
* Extension for [ExecutableFindOperation.DistinctWithProjection. as] leveraging reified type parameters.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 2.1
|
||||
*/
|
||||
inline fun <reified T : Any> ExecutableFindOperation.DistinctWithProjection.asType(): ExecutableFindOperation.DistinctWithProjection =
|
||||
inline fun <reified T : Any> ExecutableFindOperation.DistinctWithProjection.asType(): ExecutableFindOperation.TerminatingDistinct<T> =
|
||||
`as`(T::class.java)
|
||||
|
||||
@@ -68,5 +68,5 @@ fun <T : Any> ReactiveFindOperation.DistinctWithProjection.asType(resultType: KC
|
||||
* @author Christoph Strobl
|
||||
* @since 2.1
|
||||
*/
|
||||
inline fun <reified T : Any> ReactiveFindOperation.DistinctWithProjection.asType(): ReactiveFindOperation.DistinctWithProjection =
|
||||
inline fun <reified T : Any> ReactiveFindOperation.DistinctWithProjection.asType(): ReactiveFindOperation.TerminatingDistinct<T> =
|
||||
`as`(T::class.java)
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assume.*;
|
||||
import static org.springframework.data.mongodb.core.index.PartialIndexFilter.*;
|
||||
import static org.springframework.data.mongodb.core.query.Criteria.*;
|
||||
|
||||
import org.bson.BsonDocument;
|
||||
import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -40,6 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.IndexOptions;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link DefaultIndexOperations}.
|
||||
@@ -150,6 +152,21 @@ public class DefaultIndexOperationsIntegrationTests {
|
||||
assertThat(info.getPartialFilterExpression()).isEqualTo("{ \"a_g_e\" : { \"$gte\" : 10 } }");
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2388
|
||||
public void shouldReadIndexWithPartialFilterContainingDbRefCorrectly() {
|
||||
|
||||
BsonDocument partialFilter = BsonDocument.parse(
|
||||
"{ \"the-ref\" : { \"$ref\" : \"other-collection\", \"$id\" : { \"$oid\" : \"59ce08baf264b906810fe8c5\"} } }");
|
||||
IndexOptions indexOptions = new IndexOptions();
|
||||
indexOptions.name("partial-with-dbref");
|
||||
indexOptions.partialFilterExpression(partialFilter);
|
||||
|
||||
collection.createIndex(BsonDocument.parse("{ \"key-1\" : 1, \"key-2\": 1}"), indexOptions);
|
||||
|
||||
IndexInfo info = findAndReturnIndexInfo(indexOps.getIndexInfo(), "partial-with-dbref");
|
||||
assertThat(BsonDocument.parse(info.getPartialFilterExpression())).isEqualTo(partialFilter);
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1518
|
||||
public void shouldCreateIndexWithCollationCorrectly() {
|
||||
|
||||
|
||||
@@ -1,6 +1,42 @@
|
||||
Spring Data MongoDB Changelog
|
||||
=============================
|
||||
|
||||
Changes in version 2.1.13.RELEASE (2019-11-18)
|
||||
----------------------------------------------
|
||||
* DATAMONGO-2409 - Extension Function ReactiveFindOperation.DistinctWithProjection.asType() has wrong return type.
|
||||
* DATAMONGO-2401 - Release 2.1.13 (Lovelace SR13).
|
||||
|
||||
|
||||
Changes in version 2.2.1.RELEASE (2019-11-04)
|
||||
---------------------------------------------
|
||||
* DATAMONGO-2399 - Upgrade to mongo-java-driver 3.11.1.
|
||||
* DATAMONGO-2394 - nearSphere query wrongly generated with radian parameter instead of meters.
|
||||
* DATAMONGO-2393 - Reading large file from ReactiveGridFsTemplate causes a stackoverflow and the code to hang.
|
||||
* DATAMONGO-2392 - Reading GridFS files written with old api and custom id fails on ReactiveGridFsTemplate.
|
||||
* DATAMONGO-2388 - IndexOperations.getIndexInfo() fails for index that has partialFilterExpression containing DBRef.
|
||||
* DATAMONGO-2382 - Release 2.2.1 (Moore SR1).
|
||||
|
||||
|
||||
Changes in version 2.1.12.RELEASE (2019-11-04)
|
||||
----------------------------------------------
|
||||
* DATAMONGO-2388 - IndexOperations.getIndexInfo() fails for index that has partialFilterExpression containing DBRef.
|
||||
* DATAMONGO-2381 - Release 2.1.12 (Lovelace SR12).
|
||||
|
||||
|
||||
Changes in version 2.2.0.RELEASE (2019-09-30)
|
||||
---------------------------------------------
|
||||
* DATAMONGO-2380 - Remove @ExperimentalCoroutinesApi annotations.
|
||||
* DATAMONGO-2379 - Add documentation for Kotlin support.
|
||||
* DATAMONGO-2378 - Favor com.mongodb.client.MongoClient (over already deprecated com.mongodb.MongoClient) where possible.
|
||||
* DATAMONGO-2377 - Wrong processing of $$value and $$this.
|
||||
* DATAMONGO-2374 - Couldn't find PersistentEntity for type class org.bson.Document using query methods.
|
||||
* DATAMONGO-2366 - CursorReadingTask calls errorHandler.handleError twice for exception raised while reading from the cursor.
|
||||
* DATAMONGO-2361 - Trivial fix in Mapping Annotation Overview chapter of RefDoc.
|
||||
* DATAMONGO-2360 - MongoTemplate#count does not use hinted index.
|
||||
* DATAMONGO-2334 - Release 2.2 GA (Moore).
|
||||
* DATAMONGO-1731 - Improve JavaDoc of MongoOperations update / findAndModify methods.
|
||||
|
||||
|
||||
Changes in version 2.1.11.RELEASE (2019-09-30)
|
||||
----------------------------------------------
|
||||
* DATAMONGO-2377 - Wrong processing of $$value and $$this.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data MongoDB 2.1.11
|
||||
Spring Data MongoDB 2.1.13
|
||||
Copyright (c) [2010-2019] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
|
||||
Reference in New Issue
Block a user