Skip to content

Commit

Permalink
add a note
Browse files Browse the repository at this point in the history
remove a println
  • Loading branch information
evanchooly committed Jun 12, 2024
1 parent b8affdc commit d81730a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/src/main/java/dev/morphia/mapping/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ public void updateQueryWithDiscriminators(EntityModel model, Document query) {
&& !query.containsKey(model.getDiscriminatorKey())) {
List<String> values = new ArrayList<>();
List<EntityModel> classesMappedToCollection = getClassesMappedToCollection(model.getCollectionName());
// the discriminator is added here if size > 1 because, unless polymorphic queries are enabled, historically Morphia has only
// returned the type given to the query. adding the discriminator value here ensures that only the query type is returned
// unless polymorphic queries are explicitly enabled.
if (classesMappedToCollection.size() > 1 || config.enablePolymorphicQueries()) {
values.add(model.getDiscriminator());
}
Expand Down
1 change: 0 additions & 1 deletion core/src/test/java/dev/morphia/test/query/TestQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,6 @@ public void testQueryDoesNotContainDiscriminator() {
Query<TestDiscriminatorEntity> q = datastore.createQuery(TestDiscriminatorEntity.class);
q.filter(eq("something", "foo"));
Document doc = q.toDocument();
System.out.println(doc);
assertFalse(doc.containsKey("_t"), "The discriminator was found in the query document: \n"
+ doc.toJson(JSON_WRITER_SETTINGS));
});
Expand Down

0 comments on commit d81730a

Please sign in to comment.