-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mongo aggregate projection (#2950)
* Fix mongo projection against complex value * Tweak test and classes being tested * Trying to simplify reading projection result * Update AbstractMongoRepositoryOperations.java * Fix Sonar warnings
- Loading branch information
1 parent
a8d0d97
commit 477eabc
Showing
5 changed files
with
124 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
data-mongodb/src/test/java/io/micronaut/data/document/mongodb/entities/ComplexEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.micronaut.data.document.mongodb.entities; | ||
|
||
import io.micronaut.data.annotation.GeneratedValue; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
|
||
/** | ||
* An entity with one of field being complex field ie. object. | ||
* @param id The id | ||
* @param simpleValue The simple value field (String) | ||
* @param complexValue The complex value field (Object) | ||
*/ | ||
@MappedEntity | ||
public record ComplexEntity ( | ||
@Id | ||
@GeneratedValue | ||
String id, | ||
String simpleValue, | ||
ComplexValue complexValue) { | ||
ComplexEntity(String simpleValue, ComplexValue complexValue) { | ||
this(null, simpleValue, complexValue); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
data-mongodb/src/test/java/io/micronaut/data/document/mongodb/entities/ComplexValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.micronaut.data.document.mongodb.entities; | ||
|
||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
@Serdeable | ||
public record ComplexValue ( | ||
String valueA, | ||
String valueB) { | ||
} |
19 changes: 19 additions & 0 deletions
19
...rc/test/java/io/micronaut/data/document/mongodb/repositories/ComplexEntityRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.micronaut.data.document.mongodb.repositories; | ||
|
||
import io.micronaut.data.document.mongodb.entities.ComplexEntity; | ||
import io.micronaut.data.document.mongodb.entities.ComplexValue; | ||
import io.micronaut.data.mongodb.annotation.MongoRepository; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@MongoRepository | ||
public interface ComplexEntityRepository extends CrudRepository<ComplexEntity, String> { | ||
|
||
Optional<ComplexValue> findComplexValueById(String id); | ||
|
||
Optional<String> findSimpleValueById(String id); | ||
|
||
List<ComplexValue> findAllComplexValue(); | ||
} |