Compare commits
11 Commits
2.0.6.RELE
...
2.0.7.RELE
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbf4990f60 | ||
|
|
c5c43158c2 | ||
|
|
56ffe7913d | ||
|
|
eae263eebc | ||
|
|
0dd2fa3dce | ||
|
|
e648ea5903 | ||
|
|
f389812b7c | ||
|
|
2127ddcbb8 | ||
|
|
7f9ab3bb44 | ||
|
|
aea40ca490 | ||
|
|
fb8d03db31 |
6
pom.xml
6
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
<version>2.0.7.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.0.6.RELEASE</version>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -27,7 +27,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>2.0.6.RELEASE</springdata.commons>
|
||||
<springdata.commons>2.0.7.RELEASE</springdata.commons>
|
||||
<mongo>3.5.0</mongo>
|
||||
<mongo.reactivestreams>1.6.0</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.0.6.RELEASE</version>
|
||||
<version>2.0.7.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.0.6.RELEASE</version>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- reactive -->
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
<version>2.0.7.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.0.6.RELEASE</version>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class AggregationOperationRenderer {
|
||||
FieldsExposingAggregationOperation exposedFieldsOperation = (FieldsExposingAggregationOperation) operation;
|
||||
ExposedFields fields = exposedFieldsOperation.getFields();
|
||||
|
||||
if (operation instanceof InheritsFieldsAggregationOperation) {
|
||||
if (operation instanceof InheritsFieldsAggregationOperation || exposedFieldsOperation.inheritsFields()) {
|
||||
contextToUse = new InheritingExposedFieldsAggregationOperationContext(fields, contextToUse);
|
||||
} else {
|
||||
contextToUse = fields.exposesNoFields() ? DEFAULT_CONTEXT
|
||||
|
||||
@@ -33,9 +33,26 @@ public interface FieldsExposingAggregationOperation extends AggregationOperation
|
||||
*/
|
||||
ExposedFields getFields();
|
||||
|
||||
/**
|
||||
* @return {@literal true} to conditionally inherit fields from previous operations.
|
||||
* @since 2.0.6
|
||||
*/
|
||||
default boolean inheritsFields() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marker interface for {@link AggregationOperation} that inherits fields from previous operations.
|
||||
*/
|
||||
interface InheritsFieldsAggregationOperation extends FieldsExposingAggregationOperation {}
|
||||
interface InheritsFieldsAggregationOperation extends FieldsExposingAggregationOperation {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation#inheritsFields()
|
||||
*/
|
||||
@Override
|
||||
default boolean inheritsFields() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,11 +140,6 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
|
||||
*/
|
||||
public ProjectionOperation andExclude(String... fieldNames) {
|
||||
|
||||
for (String fieldName : fieldNames) {
|
||||
Assert.isTrue(Fields.UNDERSCORE_ID.equals(fieldName),
|
||||
String.format(EXCLUSION_ERROR, fieldName, Fields.UNDERSCORE_ID));
|
||||
}
|
||||
|
||||
List<FieldProjection> excludeProjections = FieldProjection.from(Fields.fields(fieldNames), false);
|
||||
return new ProjectionOperation(this.projections, excludeProjections);
|
||||
}
|
||||
@@ -188,6 +183,18 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
|
||||
return fields != null ? fields : ExposedFields.empty();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation#inheritsFields()
|
||||
*/
|
||||
@Override
|
||||
public boolean inheritsFields() {
|
||||
|
||||
return projections.stream().filter(FieldProjection.class::isInstance) //
|
||||
.map(FieldProjection.class::cast) //
|
||||
.anyMatch(FieldProjection::isExcluded);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.aggregation.AggregationOperation#toDocument(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext)
|
||||
@@ -1344,6 +1351,13 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
|
||||
return projections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@literal true} if this field is excluded.
|
||||
*/
|
||||
public boolean isExcluded() {
|
||||
return Boolean.FALSE.equals(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.aggregation.ProjectionOperation.Projection#toDocument(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext)
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.mongodb.repository.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -27,10 +28,12 @@ import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||
import org.springframework.data.mongodb.util.BsonUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.DBRef;
|
||||
@@ -93,7 +96,7 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
|
||||
return super.visit(expr, context);
|
||||
}
|
||||
|
||||
return converter.convertToMongoType(expr.getConstant());
|
||||
return toQuerydslMongoType(expr.getConstant());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -128,7 +131,8 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
|
||||
Document mappedIdValue = mapper.getMappedObject((BasicDBObject) superIdValue, Optional.empty());
|
||||
return (DBObject) JSON.parse(mappedIdValue.toJson());
|
||||
}
|
||||
return super.asDBObject(key, value instanceof Pattern ? value : converter.convertToMongoType(value));
|
||||
|
||||
return super.asDBObject(key, value instanceof Pattern ? value : toQuerydslMongoType(value));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -231,4 +235,25 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
private Object toQuerydslMongoType(Object source) {
|
||||
|
||||
Object target = converter.convertToMongoType(source);
|
||||
|
||||
if (target instanceof List) {
|
||||
|
||||
List<Object> newList = new BasicDBList();
|
||||
|
||||
for (Object item : (List) target) {
|
||||
if (item instanceof Document) {
|
||||
newList.add(new BasicDBObject(BsonUtils.asMap((Document) item)));
|
||||
} else {
|
||||
newList.add(item);
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +198,23 @@ public class ProjectionOperationUnitTests {
|
||||
assertThat(oper.get(MOD)).isEqualTo((Object) Arrays.<Object> asList("$a", 3));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAMONGO-758
|
||||
public void excludeShouldThrowExceptionForFieldsOtherThanUnderscoreId() {
|
||||
@Test // DATAMONGO-758, DATAMONGO-1893
|
||||
public void excludeShouldAllowExclusionOfFieldsOtherThanUnderscoreId/* since MongoDB 3.4 */() {
|
||||
|
||||
new ProjectionOperation().andExclude("foo");
|
||||
ProjectionOperation projectionOp = new ProjectionOperation().andExclude("foo");
|
||||
Document document = projectionOp.toDocument(Aggregation.DEFAULT_CONTEXT);
|
||||
Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT);
|
||||
|
||||
assertThat(projectionOp.inheritsFields()).isTrue();
|
||||
assertThat((Integer) projectClause.get("foo")).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1893
|
||||
public void includeShouldNotInheritFields() {
|
||||
|
||||
ProjectionOperation projectionOp = new ProjectionOperation().andInclude("foo");
|
||||
|
||||
assertThat(projectionOp.inheritsFields()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-758
|
||||
|
||||
@@ -22,6 +22,8 @@ import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
|
||||
import static org.springframework.data.mongodb.core.aggregation.Fields.*;
|
||||
import static org.springframework.data.mongodb.test.util.IsBsonObject.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,8 +37,8 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mongodb.core.aggregation.ExposedFields.DirectFieldReference;
|
||||
@@ -188,6 +190,19 @@ public class TypeBasedAggregationOperationContextUnitTests {
|
||||
.containing("age", "$age.value"));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1893
|
||||
public void considersIncludedFieldsFromSingleExclusionsCorrectly() {
|
||||
|
||||
AggregationOperationContext context = getContext(FooPerson.class);
|
||||
TypedAggregation<FooPerson> agg = newAggregation(FooPerson.class, project() //
|
||||
.andExclude("name"), sort(Sort.by("age.value", "lastName")));
|
||||
|
||||
Document dbo = agg.toDocument("person", context);
|
||||
|
||||
Document sort = getPipelineElementFromAggregationAt(dbo, 1);
|
||||
assertThat(getAsDocument(sort, "$sort"), is(equalTo(new Document("age.value", 1).append("last_name", 1))));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1133
|
||||
public void shouldHonorAliasedFieldsInGroupExpressions() {
|
||||
|
||||
@@ -344,18 +359,13 @@ public class TypeBasedAggregationOperationContextUnitTests {
|
||||
}
|
||||
|
||||
@org.springframework.data.mongodb.core.mapping.Document(collection = "person")
|
||||
@AllArgsConstructor
|
||||
public static class FooPerson {
|
||||
|
||||
final ObjectId id;
|
||||
final String name;
|
||||
@org.springframework.data.mongodb.core.mapping.Field("last_name") final String lastName;
|
||||
final Age age;
|
||||
|
||||
@PersistenceConstructor
|
||||
FooPerson(ObjectId id, String name, Age age) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Age {
|
||||
|
||||
@@ -45,6 +45,8 @@ import org.springframework.data.mongodb.repository.QPerson;
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.util.JSON;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.BooleanOperation;
|
||||
import com.querydsl.core.types.dsl.PathBuilder;
|
||||
import com.querydsl.core.types.dsl.SimplePath;
|
||||
@@ -184,6 +186,16 @@ public class SpringDataMongodbSerializerUnitTests {
|
||||
assertThat(((DBObject) mappedPredicate).get("sex"), is((Object) "f"));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1943
|
||||
public void shouldRemarshallListsAndDocuments() {
|
||||
|
||||
BooleanExpression criteria = QPerson.person.firstname.isNotEmpty()
|
||||
.and(QPerson.person.firstname.containsIgnoreCase("foo")).not();
|
||||
|
||||
assertThat(this.serializer.handle(criteria), is(equalTo(JSON.parse("{ \"$or\" : [ { \"firstname\" : { \"$ne\" : { "
|
||||
+ "\"$ne\" : \"\"}}} , { \"firstname\" : { \"$not\" : { \"$regex\" : \".*\\\\Qfoo\\\\E.*\" , \"$options\" : \"i\"}}}]}"))));
|
||||
}
|
||||
|
||||
class Address {
|
||||
String id;
|
||||
String street;
|
||||
|
||||
@@ -1,6 +1,56 @@
|
||||
Spring Data MongoDB Changelog
|
||||
=============================
|
||||
|
||||
Changes in version 2.0.7.RELEASE (2018-05-08)
|
||||
---------------------------------------------
|
||||
* DATAMONGO-1943 - QueryDSL functionality defect while using NOT operator for negate operation.
|
||||
* DATAMONGO-1918 - Release 2.0.7 (Kay SR7).
|
||||
* DATAMONGO-1893 - Exclusions in projection.
|
||||
* DATAMONGO-1819 - Discovering the preferred constructor lead to InaccessibleObjectException with Java 9.
|
||||
|
||||
|
||||
Changes in version 1.10.12.RELEASE (2018-05-08)
|
||||
-----------------------------------------------
|
||||
* DATAMONGO-1917 - Release 1.10.12 (Ingalls SR12).
|
||||
* DATAMONGO-1893 - Exclusions in projection.
|
||||
|
||||
|
||||
Changes in version 2.1.0.M2 (2018-04-13)
|
||||
----------------------------------------
|
||||
* DATAMONGO-1923 - Adapt to API changes in Spring Data Commons.
|
||||
* DATAMONGO-1916 - Potential ClassCastException in MappingMongoConverter#writeInternal when writing collections.
|
||||
* DATAMONGO-1915 - Remove explicit declaration of Jackson library versions.
|
||||
* DATAMONGO-1913 - Missing @Nullable annotation in GridFsTemplate.bucket.
|
||||
* DATAMONGO-1912 - Unable to retrieve Mongo's generated id when inserting java.util.Map.
|
||||
* DATAMONGO-1911 - String-query accepting UUID renders to $uuid.
|
||||
* DATAMONGO-1909 - Fix typo in tests.
|
||||
* DATAMONGO-1907 - Error in method findOne(Example example) in ReactiveQueryByExampleExecutor when there is no results.
|
||||
* DATAMONGO-1906 - Add support for conditional $$REMOVE operator in aggregation $project.
|
||||
* DATAMONGO-1904 - MappingMongoConverter fails to properly read nested arrays.
|
||||
* DATAMONGO-1903 - Align database name check in SimpleMongoDbFactory with MongoDB limitations.
|
||||
* DATAMONGO-1901 - Declare project.root property to make sure JavaDoc generation works.
|
||||
* DATAMONGO-1900 - Add section to reference documentation about mapping of enums with interfaces.
|
||||
* DATAMONGO-1899 - Export composable repositories via CDI.
|
||||
* DATAMONGO-1898 - Verify handling of enums in MappingMongoConverter.
|
||||
* DATAMONGO-1896 - In case of inheritance, MongoRepository.saveAll(…) does not insert elements into the aggregate collection.
|
||||
* DATAMONGO-1893 - Exclusions in projection.
|
||||
* DATAMONGO-1891 - Improve $jsonSchema documentation.
|
||||
* DATAMONGO-1881 - Upgrade MongoDB sync & reactive streams Java driver to 3.6.3 and 1.7.1.
|
||||
* DATAMONGO-1880 - Add support for Client Sessions.
|
||||
* DATAMONGO-1877 - JsonSchemaProperty needs static method date().
|
||||
* DATAMONGO-1873 - Add value() alias to @Document(collection= "…").
|
||||
* DATAMONGO-1872 - SpEL Expressions in @Document annotations are not re-evaluated for repository query executions.
|
||||
* DATAMONGO-1871 - AggregationExpression rendering does not consider nested property aliasing.
|
||||
* DATAMONGO-1870 - Skip parameter not working in MongoTemplate#remove(Query, Class).
|
||||
* DATAMONGO-1869 - Release 2.1 M2 (Lovelace).
|
||||
* DATAMONGO-1866 - Update travis build to use single node replica set.
|
||||
* DATAMONGO-1865 - findFirst query method throws IncorrectResultSizeDataAccessException on non-unique result.
|
||||
* DATAMONGO-1860 - Mongo count operation called twice in QuerydslMongoPredicateExecutor.findAll(Predicate, Pageable).
|
||||
* DATAMONGO-1834 - Add support for aggregation operators $dateFromString, $dateFromParts and $dateToParts.
|
||||
* DATAMONGO-1819 - Discovering the preferred constructor lead to InaccessibleObjectException with Java 9.
|
||||
* DATAMONGO-1813 - Provide method to create GridFsResource from GridFSFile.
|
||||
|
||||
|
||||
Changes in version 2.0.6.RELEASE (2018-04-04)
|
||||
---------------------------------------------
|
||||
* DATAMONGO-1916 - Potential ClassCastException in MappingMongoConverter#writeInternal when writing collections.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data MongoDB 2.0.6
|
||||
Spring Data MongoDB 2.0.7
|
||||
Copyright (c) [2010-2015] 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