You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From version 5.18.0, the apoc.cypher.runSchemaFile does not seem to work as correctly as before, if an EquivalentSchemaRuleAlreadyExistsException is thrown.
But it's probably a kernel problem,
as I have isolated the problem, and created a simple test case, as follows:
import apoc.util.TestUtil;
import org.junit.*;
import org.neo4j.graphdb.*;
import org.neo4j.procedure.*;
import org.neo4j.test.rule.*;
import java.util.Map;
import java.util.stream.Stream;
public class PendingTest {
public static class MockProcedure {
public record MockResult(String value) {}
@Context public GraphDatabaseService db;
@Procedure(name = "my.proc", mode = Mode.SCHEMA)
public Stream<MockResult> myProcedure() {
// should throw an EquivalentSchemaRuleAlreadyExistsException,
// instead it remains in pending
db.executeTransactionally("CREATE CONSTRAINT FOR (n:Person) REQUIRE n.name IS UNIQUE", Map.of(), Result::resultAsString);
return Stream.of(new MockResult("test"));
}
}
@ClassRule
public static DbmsRule db = new ImpermanentDbmsRule();
@BeforeClass
public static void setUp() {
TestUtil.registerProcedure(db, MockProcedure.class);
}
@Test
public void test() {
db.executeTransactionally("CREATE CONSTRAINT FOR (n:Person) REQUIRE n.name IS UNIQUE");
try {
// it throws an EquivalentSchemaRuleAlreadyExistsException and remains in pending
db.executeTransactionally("CALL my.proc()", Map.of(), Result::resultAsString);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("equivalent constraint already exists"));
}
}
}
Additional notes
The issue also occurs with a test container and with a real Neo4j instance.
Up to 5.17.0 the test case works correctly
By changing the MockProcedure class to the following, solves the problem:
public static class MockProcedure {
public record MockResult(String value) {}
@Context public Transaction tx;
@Procedure(name = "my.proc", mode = Mode.SCHEMA)
public Stream<MockResult> myProcedure() {
tx.execute("CREATE CONSTRAINT FOR (n:Person) REQUIRE n.name IS UNIQUE", Map.of()).resultAsString();
return Stream.of(new MockResult("test"));
}
}
Expected behavior
The procedure correctly ends the execution
Actual behavior
The procedure remains in pending
Neo4j version: 5.18.0
Operating system: Mac OS Ventura
API/Driver: Java API/Cypher
The text was updated successfully, but these errors were encountered:
From version 5.18.0, the
apoc.cypher.runSchemaFile
does not seem to work as correctly as before, if anEquivalentSchemaRuleAlreadyExistsException
is thrown.I created an issue in the APOC repo.
But it's probably a kernel problem,
as I have isolated the problem, and created a simple test case, as follows:
Additional notes
Expected behavior
The procedure correctly ends the execution
Actual behavior
The procedure remains in pending
The text was updated successfully, but these errors were encountered: