@@ -345,4 +345,65 @@ void regressionIssue2267SeparateVertexTypeImports() throws Exception {
345345 TestHelper .checkActiveDatabases ();
346346 }
347347
348+ /**
349+ * Regression test for GitHub issue #3713: IMPORT DATABASE rejects edgeBidirectional = false
350+ * When edgeBidirectional=false is specified, the edge type should be created as non-bidirectional
351+ * so that unidirectional edges can be imported without error.
352+ */
353+ @ Test
354+ void regressionIssue3713EdgeBidirectionalFalse () {
355+ final String databasePath = "target/databases/test-import-edge-unidirectional" ;
356+
357+ final DatabaseFactory databaseFactory = new DatabaseFactory (databasePath );
358+ if (databaseFactory .exists ())
359+ databaseFactory .open ().drop ();
360+
361+ // Import vertices first
362+ Importer importer = new Importer (new String [] {
363+ "-vertices" , "src/test/resources/importer-vertices.csv" ,
364+ "-database" , databasePath ,
365+ "-typeIdProperty" , "Id" ,
366+ "-typeIdType" , "Long" ,
367+ "-typeIdPropertyIsUnique" , "true" ,
368+ "-forceDatabaseCreate" , "true"
369+ });
370+ importer .load ();
371+
372+ // Import edges with edgeBidirectional=false — this was throwing IllegalArgumentException before the fix
373+ importer = new Importer (new String [] {
374+ "-edges" , "src/test/resources/importer-edges.csv" ,
375+ "-database" , databasePath ,
376+ "-typeIdProperty" , "Id" ,
377+ "-typeIdType" , "Long" ,
378+ "-edgeFromField" , "From" ,
379+ "-edgeToField" , "To" ,
380+ "-edgeBidirectional" , "false"
381+ });
382+ importer .load ();
383+
384+ try (final Database db = databaseFactory .open ()) {
385+ assertThat (db .countType ("Node" , true )).isEqualTo (6 );
386+ assertThat (db .countType ("Relationship" , true )).as ("All 3 edges should be imported" ).isEqualTo (3 );
387+
388+ // Verify edge type is non-bidirectional
389+ assertThat (((com .arcadedb .schema .EdgeType ) db .getSchema ().getType ("Relationship" )).isBidirectional ()).isFalse ();
390+
391+ // Verify outgoing edges exist
392+ var vertex0 = db .lookupByKey ("Node" , "Id" , 0 ).next ().getRecord ().asVertex ();
393+ assertThat (vertex0 .countEdges (Vertex .DIRECTION .OUT , "Relationship" ))
394+ .as ("Vertex 0 should have 2 outgoing edges" ).isEqualTo (2 );
395+
396+ // For unidirectional edges, incoming edges should NOT be tracked
397+ var vertex1 = db .lookupByKey ("Node" , "Id" , 1 ).next ().getRecord ().asVertex ();
398+ assertThat (vertex1 .countEdges (Vertex .DIRECTION .OUT , "Relationship" ))
399+ .as ("Vertex 1 should have 1 outgoing edge (1->4)" ).isEqualTo (1 );
400+ assertThat (vertex1 .countEdges (Vertex .DIRECTION .IN , "Relationship" ))
401+ .as ("Vertex 1 should have 0 incoming edges (unidirectional)" ).isEqualTo (0 );
402+ }
403+
404+ databaseFactory .open ().drop ();
405+
406+ TestHelper .checkActiveDatabases ();
407+ }
408+
348409}
0 commit comments