Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringDataMongodbQuery and SpringDataMongodbSerializer apply mapping twice #4709

Closed
bro0k opened this issue May 28, 2024 · 1 comment
Closed
Assignees
Labels
type: bug A general bug

Comments

@bro0k
Copy link

bro0k commented May 28, 2024

# Entity class example
@Document(collection = "record")
public class Record {
    @Id
    private String id;

    @Field("embedded_object")
    private EmbeddedObject embeddedObject;
}

@Document(collection = "embedded_object")
public class EmbeddedObject {
    @Id
    private String id;
}

# Query code example
recordRepository.findAll(QRecord.record.embeddedObject.id.eq("64268a7b17ac6a00018bf312"), PageRequest.of(0,1))

# Expected correct result
find using query: { "embedded_object._id" : { "$oid" : "64268a6117ac6a00018bf30f"}} fields: Document{{}} 

# Actual incorrect result
find using query: { "embedded_object._id" : "64268a6117ac6a00018bf30f"} fields: Document{{}} 

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 28, 2024
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 28, 2024
@mp911de mp911de changed the title The createQueryFor(predicate) Method in QuerydslMongoPredicateExecutor Converts Query Conditions with Nested Objects Containing ObjectId() to Strings SpringDataMongodbQuery and SpringDataMongodbSerializer apply mapping twice May 28, 2024
@mp911de
Copy link
Member

mp911de commented May 28, 2024

SpringDataMongodbSerializer used via QuerydslMongoPredicateExecutor applies field name customization twice. The resulting query above (used with the QueryMapper) is embedded_object._id while it should be embeddedObject.id. Removing field name mapping in SpringDataMongodbSerializer seems not enough as other components break.

@mp911de mp911de added this to the 4.2.7 (2023.1.7) milestone Jun 11, 2024
mp911de pushed a commit that referenced this issue Jun 11, 2024
This commit makes sure to convert the generated query into the target type.

Closes #4709
Original pull request: #4721
mp911de added a commit that referenced this issue Jun 11, 2024
Reformat code, revise nullability declarations.

See #4709
Original pull request: #4721
mp911de added a commit that referenced this issue Jun 11, 2024
Reformat code, revise nullability declarations.

See #4709
Original pull request: #4721
mp911de pushed a commit that referenced this issue Jun 11, 2024
This commit makes sure to convert the generated query into the target type.

Closes #4709
Original pull request: #4721
mp911de added a commit that referenced this issue Jun 11, 2024
Reformat code, revise nullability declarations.

See #4709
Original pull request: #4721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
4 participants