anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: grails/gorm-neo4j
Issue: Old relationships are not deleted

Having this classes:

```
class Player  {

    String name
    Application application

    static mapping = {
        dynamicAssociations true
    }

}


class Application {

    String name
    String appVersion

    static constraints = {
        appVersion nullable: true
    }
}

```

I create a player1 with an Application app1. Then in a controller actuib I update the player's application to be app2 but in the database I see both relationships:
```
neo4j-sh (?)$ ls -a 48
:Player
*dateCreated =[1492546127413]
*lastUpdated =[1492546127413]
*name        =[player1]
*version     =[0]
(player1,48)-[:club]->(club2,47)
(player1,48)-[:APPLICATION]->(app2,45)
(player1,48)-[:APPLICATION]->(app1,44)
```

You can reproduce this by downloading the project at https://github.com/mburak/sampleapp, branch 'dup-assoc'.
1 - Start up the app
2 - Access rest controller action club/updatePlayer

Changed files:
grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/RelationshipPendingInsert.java

diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/RelationshipPendingInsert.java b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/RelationshipPendingInsert.java
index 99d0a8ae..0d7be589 100644
--- a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/RelationshipPendingInsert.java
+++ b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/RelationshipPendingInsert.java
@@ -148,12 +148,15 @@ public class RelationshipPendingInsert extends PendingInsertAdapter<Object, Seri
             relMatch = RelationshipUtils.matchForAssociation(association, "r");
         }
 
-        if(isUpdate && (association instanceof DynamicAssociation || (association.isBidirectional() && (association instanceof OneToMany)) && !RelationshipUtils.useReversedMappingFor(association))) {
+        if(isUpdate &&
+           (association instanceof DynamicAssociation ||
+            ((association.isBidirectional() && (association instanceof OneToMany)) || (association instanceof OneToOne)) &&
+            !RelationshipUtils.useReversedMappingFor(association))) {
             // delete any previous
 
             StringBuilder cypher = new StringBuilder(CypherBuilder.buildRelationshipMatch(labelsFrom, relMatch, labelsTo));
             Map<String, Object> deleteParams;
-            if(association instanceof DynamicToOneAssociation) {
+            if(association instanceof DynamicToOneAssociation || association instanceof OneToOne) {
                 cypher.append(graphChild.formatId(FROM));
                 deleteParams = Collections.<String, Object>singletonMap(CypherBuilder.START, Collections.singletonList(parentId));
             }