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
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ public String getName() {
267
267
*/
268
268
public String getTarget () {
269
269
270
- if (isLocalVar ()) {
270
+ if (isLocalVar () || pointsToDBRefId () ) {
271
271
return this .getRaw ();
272
272
}
273
273
@@ -296,6 +296,10 @@ public boolean isLocalVar() {
296
296
return raw .startsWith ("$$" ) && !raw .startsWith ("$$$" );
297
297
}
298
298
299
+ protected boolean pointsToDBRefId () { // see https://jira.mongodb.org/browse/SERVER-14466
300
+ return raw .endsWith (".$id" );
301
+ }
302
+
299
303
/**
300
304
* @return
301
305
* @since 1.10
Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ public void stripsLeadingDollarsFromTarget() {
117
117
assertThat (Fields .field ("$$$$target" ).getTarget ()).isEqualTo ("target" );
118
118
}
119
119
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
+
120
127
private static void verify (Field field , String name , String target ) {
121
128
122
129
assertThat (field ).isNotNull ();
You can’t perform that action at this time.
0 commit comments