Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parameterize Node DynamicLabels #3034

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

Open
garbybaby wants to merge 1 commit into spring-projects:7.4.x
base: 7.4.x
Choose a base branch
Loading
from garbybaby:parameterize_label_dynamic

Conversation

Copy link

@garbybaby garbybaby commented Aug 7, 2025

  • You have read the Spring Data Neo4j contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Signed-off-by: Garby Baby <garbybaby@gmail.com>
@garbybaby garbybaby changed the title (削除) Parametrize Node DynamicLabels (削除ここまで) (追記) Parameterize Node DynamicLabels (追記ここまで) Aug 7, 2025
@@ -303,6 +303,10 @@ public Statement prepareSaveOf(NodeDescription<?> nodeDescription,
String primaryLabel = nodeDescription.getPrimaryLabel();
List<String> additionalLabels = nodeDescription.getAdditionalLabels();

List<String> additionalLabelsNew = new ArrayList<>(additionalLabels);
additionalLabelsNew.addAll(nodeDescription.getDynamicLabels());
Node rootNodeWithDynamicLabels = node(primaryLabel, additionalLabelsNew).named(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription));
Copy link

@zakjan zakjan Aug 22, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still generates a non-parametrized query for @DynamicLabels.

@@ -60,4 +66,8 @@ public OngoingMatchAndUpdate apply(OngoingMatchAndUpdate ongoingMatchAndUpdate)
}
Copy link

@zakjan zakjan Aug 22, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oldLabels.toArray(new String[0]) -> Cypher.parameter("oldLabels")
newLabels.toArray(new String[0]) -> Cypher.parameter("newLabels")

Parameter names are to be added to Constants and populated to the query when running it.

michael-simons reacted with thumbs up emoji
Copy link
Collaborator

Hej there. Thanks for the PR.

There are no tests, hence I might be wrong in my assumption that the change will require an additional set of additional labels next to the additional labels we already have, that you called dynamic labels?
If so, this is not the approach we would like to support.

SDN does support dynamic labels already on the mapping side of things. The goal must be to translate those to either

  • what there is now, building a static query for all the old versions of neo4j
  • or translating it to proper dynamic Cypher labels

For the latter we would of course be using Cypher DSL. Over there, we don't support dynamic label expressions yet.

Hence, I think we should add this there, and than rely on the configured dialect so that Cypher-DSL does the correct thing.

Copy link
Collaborator

I created in issue for the Cypher-DSL work neo4j/cypher-dsl#1314

Copy link

zakjan commented Sep 2, 2025

@michael-simons By dynamic labels we meant only labels managed by SDN in @DynamicLabels, no more. It's good if Cypher DSL can support both static and dynamic labels depending on the dialect selection, when the labels are provided from a dynamic array. Static schema labels should stay static as-is to be eligible for planning with indexes. Dynamic labels don't use indexes well (docs) but this should be fine given their non-schema purpose.

Copy link

zakjan commented Sep 2, 2025

@michael-simons Would you mind if we close this PR and leave it for you to finish the implementation? Given the missing and upcoming support in Cypher DSL, it's apparent it's more complex then we thought :)

Copy link
Collaborator

@zakjan I got that (wrt dynamic labels), and I do fully get behind that we should translate the SDN feature to the new Cypher feature. We should have done this before.

Wrt this PR, do as you see fit, I am fine with both keeping it open or doing a fresh. Happy to help you and your colleague to get PR in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
1 more reviewer

@zakjan zakjan zakjan left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /