Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ data class DeleteRelationship(
)
}

if (start.ids.isEmpty() || end.ids.isEmpty()) {
throw InvalidDataException(
"'${Keys.FROM}' and '${Keys.TO}' must contain at least one ID property."
)
}

val startParam = Cypher.parameter("start")
val endParam = Cypher.parameter("end")
val keysParam = Cypher.parameter("keys")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,57 @@ class CudHandlerTest : HandlerTest() {
)
}

@Test
fun `should delete relationship without constraint on 'from' or 'to'`() {
val handler = CudHandler("my-topic", Renderer.getDefaultRenderer(), 100)

val sinkMessage =
newMessage(
Schema.STRING_SCHEMA,
"""
{
"type": "relationship",
"op": "DELETE",
"rel_type": "RELATED_TO",
"from": {
"labels": ["Foo"],
"ids": {}
},
"to": {
"labels": ["Bar"],
"ids": {}
}
}
""",
)
handler.handle(listOf(sinkMessage)) shouldBe
listOf(
listOf(
ChangeQuery(
null,
null,
listOf(sinkMessage),
Query(
CypherParser.parse(
"""
MATCH (start:`Foo` {}) WITH start
MATCH (end:`Bar` {}) WITH start, end
MATCH (start)-[r:`RELATED_TO` {}]->(end)
DELETE r
"""
)
.cypher,
mapOf(
"start" to mapOf("keys" to emptyMap<String, Any?>()),
"end" to mapOf("keys" to emptyMap()),
"keys" to emptyMap()
),
),
)
)
)
}

@ParameterizedTest
@ValueSource(ints = [1, 6, 25, 100])
fun `should support mixed operations with different batch sizes`(batchSize: Int) {
Expand Down