-
Notifications
You must be signed in to change notification settings - Fork 617
Composite property issue: removing entry doesn't work #2449
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
Comments
Hi @gonzalad thanks for taking the time to fill an issue. This one is a duplicate of #2280. Elements in a composite property must be set explicitly to literal Why is that? Because SDN6 is "session free" or in other words, it doesn't keep a cache of your loaded entities around and therefor does not know what was there when an entity was loaded. In Neo4j Therefor your test can be fixed like this: @Test
void removeEntryInCompositePropertyShouldRemoveEntryInDb() {
Map composite = new HashMap(Map.ofEntries(
Map.entry("entry1", "value1"),
Map.entry("entry2", "value2")
));
SampleEntity entity = createSample(composite);
assertThat(entity.getComposite()).hasSize(2);
entity.getComposite().put("entry1", null);
sampleRepository.save(entity);
Optional<SampleEntity> entityInDatabase = sampleRepository.findById(entity.getId());
assertThat(entityInDatabase)
.isPresent()
.hasValueSatisfying(v -> {
assertThat(v.getName()).isEqualTo(entity.getName());
assertThat(v.getComposite())
.hasSize(1)
.containsEntry("entry2", Values.value("value2"));
});
} I personally would add a method such as |
Thanks @michael-simons, sorry I missed the initial issue ! |
My pleasure, and no problem. |
Hello,
I'm using SDN 6.2.0.
When I remove an entry from a composite property.
Then I expect the entry to be removed from the database node.
But the entry is not removed.
I think the issue originates from the Neo4j query generated by SDN in CypherGenerator#prepareSaveOf (I assume the += in the second match):
Thanks !
Sample
Test case:
Reproducing the issue
The issue can be reproduced by running the unit test from this sample project:
https://github.com/gonzalad/sdn6-tests/tree/issue-composite-properties by running the unit test: Sdn6Test#removeEntryInCompositePropertyShouldRemoveEntryInDb (https://github.com/gonzalad/sdn6-tests/blob/issue-composite-properties/src/test/java/com/example/sdn6/Sdn6Test.java#L29)
The text was updated successfully, but these errors were encountered: