File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
main/java/org/springframework/data/mongodb/core/aggregation
test/java/org/springframework/data/mongodb/core/aggregation Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ public String getName() {
267267 */
268268 public String getTarget () {
269269
270- if (isLocalVar ()) {
270+ if (isLocalVar () || pointsToDBRefId () ) {
271271 return this .getRaw ();
272272 }
273273
@@ -296,6 +296,10 @@ public boolean isLocalVar() {
296296 return raw .startsWith ("$$" ) && !raw .startsWith ("$$$" );
297297 }
298298
299+ protected boolean pointsToDBRefId () { // see https://jira.mongodb.org/browse/SERVER-14466
300+ return raw .endsWith (".$id" );
301+ }
302+
299303 /**
300304 * @return
301305 * @since 1.10
Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ public void stripsLeadingDollarsFromTarget() {
117117 assertThat (Fields .field ("$$$$target" ).getTarget ()).isEqualTo ("target" );
118118 }
119119
120+ @ Test // GH-4123
121+ public void keepsRawMappingToDbRefId () {
122+
123+ assertThat (Fields .field ("$id" ).getName ()).isEqualTo ("id" );
124+ assertThat (Fields .field ("person.$id" ).getTarget ()).isEqualTo ("person.$id" );
125+ }
126+
120127 private static void verify (Field field , String name , String target ) {
121128
122129 assertThat (field ).isNotNull ();
You can’t perform that action at this time.
0 commit comments