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

Nested object mapping for custom CYPHER query cut off since SDN 7.3.2 #2963

Closed
ruempel opened this issue Oct 24, 2024 · 2 comments
Closed

Nested object mapping for custom CYPHER query cut off since SDN 7.3.2 #2963

ruempel opened this issue Oct 24, 2024 · 2 comments
Assignees
Labels
type: regression A regression from a previous release

Comments

@ruempel
Copy link

ruempel commented Oct 24, 2024

We are heavily using custom CYPHER queries in CRUD repositories for performance reasons.

Since SDN 7.3.2, nested objects queried by relations are not mapped anymore. It worked until SDN 7.3.1.

If you use this custom query, the nested object is null now:

public interface MyRepository extends CrudRepository<MyModel, String> {

    @Query("""
            MATCH (root:MyModel {uuid: $uuid})
            RETURN root {
                     .*, MyModel_REL_TO_MY_NESTED_MODEL_MyModel: [
                       (root)-[:REL_TO_MY_NESTED_MODEL]->(nested:MyModel) | nested {. *}
                     ]
                   }
            """)
    Optional<MyModel> getByUuidCustomQuery(String uuid);
}

For your convenience, I prepared a minimum example Git repo with a test case, where you can try it out: https://github.com/planyverse/sdn-example

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 24, 2024
@ruempel ruempel changed the title Nested object mapping for custom CYPHER query cut off since SDN 3.3.2 Nested object mapping for custom CYPHER query cut off since SDN 7.3.2 Oct 24, 2024
@michael-simons michael-simons self-assigned this Oct 24, 2024
@michael-simons
Copy link
Collaborator

Hello @ruempel Thanks a lot for your report. This is a regression directly related to #2918 The fixed by @ma-ku adds the direction to the collection name, and I didn't spot the use case of custom queries when merging it, my bad, sorry.

I am working on a fix that does not require changes on your side. Until this is available, you would be able to fix it by adding true for the outgoing relationship to the query:

public interface MyRepository extends CrudRepository<MyModel, String> {

    @Query("""
            MATCH (root:MyModel {uuid: $uuid})
            RETURN root {
                     .*, MyModel_REL_TO_MY_NESTED_MODEL_MyModel_true: [
                       (root)-[:REL_TO_MY_NESTED_MODEL]->(nested:MyModel) | nested {. *}
                     ]
                   }
            """)
    Optional<MyModel> getByUuidCustomQuery(String uuid);
}

or false, if it is incoming.

@michael-simons michael-simons added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 24, 2024
@michael-simons
Copy link
Collaborator

(Excellent reproducer and bisection, thank you for that!)

michael-simons added a commit that referenced this issue Oct 24, 2024
…ut directional prefix.

This is a direct follow up on #2918, in which we added the suffix to the collection names. That change didn’t take custom queries into account and people are most likely still using the known pattern of `source_REL_target` and I would like to not break them.
Therefor, we check now in the values list if a collection without suffix exists if we didn’t find one with and if so, use that.

This fixes #2963.
michael-simons added a commit that referenced this issue Oct 24, 2024
…ut directional prefix.

This is a direct follow up on #2918, in which we added the suffix to the collection names. That change didn’t take custom queries into account and people are most likely still using the known pattern of `source_REL_target` and I would like to not break them.
Therefor, we check now in the values list if a collection without suffix exists if we didn’t find one with and if so, use that.

This fixes #2963.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants