File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/org/springframework/data/mongodb/core/query
test/java/org/springframework/data/mongodb/core/query Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 3737 * @author Mark Paluch
3838 * @author Owen Q
3939 * @author Kirill Egorov
40+ * @author GaEun Kim
4041 */
4142public class Field {
4243
@@ -286,7 +287,7 @@ public boolean equals(@Nullable Object o) {
286287 @ Override
287288 public int hashCode () {
288289
289- int result = ObjectUtils .nullSafeHashCode (criteria );
290+ int result = ObjectUtils .nullSafeHashCode (criteria . toString () );
290291 result = 31 * result + ObjectUtils .nullSafeHashCode (slices );
291292 result = 31 * result + ObjectUtils .nullSafeHashCode (elemMatches );
292293 result = 31 * result + ObjectUtils .nullSafeHashCode (positionKey );
Original file line number Diff line number Diff line change 2828 * @author Owen Q
2929 * @author Mark Paluch
3030 * @author Kirill Egorov
31+ * @author GaEun Kim
3132 */
3233class FieldUnitTests {
3334
@@ -85,4 +86,18 @@ void overriddenExclusionMethodsCreateEqualFields() {
8586
8687 assertThat (left ).isEqualTo (right );
8788 }
89+
90+ @ Test
91+ void assertDifferentHashCodesForExcludeAndIncludeQueries () {
92+
93+ Query queryWithExclude = new Query ();
94+ queryWithExclude .fields ().exclude ("key1" );
95+ queryWithExclude .fields ().exclude ("key2" );
96+
97+ Query queryWithInclude = new Query ();
98+ queryWithInclude .fields ().include ("key1" );
99+ queryWithInclude .fields ().include ("key2" );
100+
101+ assertThat (queryWithExclude .hashCode ()).isNotEqualTo (queryWithInclude .hashCode ());
102+ }
88103}
You can’t perform that action at this time.
0 commit comments