|
119 | 119 | import org.springframework.data.neo4j.integration.issues.gh2576.College;
|
120 | 120 | import org.springframework.data.neo4j.integration.issues.gh2576.CollegeRepository;
|
121 | 121 | import org.springframework.data.neo4j.integration.issues.gh2576.Student;
|
| 122 | +import org.springframework.data.neo4j.integration.issues.gh2579.ColumnNode; |
| 123 | +import org.springframework.data.neo4j.integration.issues.gh2579.TableAndColumnRelation; |
| 124 | +import org.springframework.data.neo4j.integration.issues.gh2579.TableNode; |
| 125 | +import org.springframework.data.neo4j.integration.issues.gh2579.TableRepository; |
122 | 126 | import org.springframework.data.neo4j.integration.misc.ConcreteImplementationTwo;
|
123 | 127 | import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
124 | 128 | import org.springframework.data.neo4j.repository.query.QueryFragmentsAndParameters;
|
@@ -866,6 +870,43 @@ void listOfMapsShouldBeUsableAsArgumentsWithWorkaround(@Autowired Neo4jTemplate
|
866 | 870 | assertThat(uuids).containsExactly(student.getGuid());
|
867 | 871 | }
|
868 | 872 |
|
| 873 | + @Test |
| 874 | + @Tag("GH-2579") |
| 875 | + void unwindWithMergeShouldWork(@Autowired Neo4jTemplate template, @Autowired TableRepository tableRepository) { |
| 876 | + |
| 877 | + TableNode tableNode = new TableNode(); |
| 878 | + tableNode.setName("t1"); |
| 879 | + tableNode.setSchemaName("a"); |
| 880 | + tableNode.setSourceName("source1"); |
| 881 | + tableNode = template.save(tableNode); |
| 882 | + |
| 883 | + ColumnNode c1 = new ColumnNode(); |
| 884 | + c1.setName("c1"); |
| 885 | + c1.setSchemaName("a"); |
| 886 | + c1.setSourceName("source1"); |
| 887 | + c1.setTableName(tableNode.getName()); |
| 888 | + long c1Id = template.save(c1).getId(); |
| 889 | + |
| 890 | + ColumnNode c2 = new ColumnNode(); |
| 891 | + c2.setName("c2"); |
| 892 | + c2.setSchemaName("a"); |
| 893 | + c2.setSourceName("source2"); |
| 894 | + c2.setTableName(tableNode.getName()); |
| 895 | + long c2Id = template.save(c2).getId(); |
| 896 | + |
| 897 | + tableRepository.mergeTableAndColumnRelations(List.of(c1, c2), tableNode); |
| 898 | + |
| 899 | + Optional<TableNode> resolvedTableNode = tableRepository.findById(tableNode.getId()); |
| 900 | + assertThat(resolvedTableNode) |
| 901 | + .map(TableNode::getTableAndColumnRelation) |
| 902 | + .hasValueSatisfying(l -> { |
| 903 | + assertThat(l) |
| 904 | + .map(TableAndColumnRelation::getColumnNode) |
| 905 | + .map(ColumnNode::getId) |
| 906 | + .containsExactlyInAnyOrder(c1Id, c2Id); |
| 907 | + }); |
| 908 | + } |
| 909 | + |
869 | 910 | @Configuration
|
870 | 911 | @EnableTransactionManagement
|
871 | 912 | @EnableNeo4jRepositories(namedQueriesLocation = "more-custom-queries.properties")
|
|
0 commit comments