Skip to content

JSON Importer does not use the merge strategy #1492

Description

@lvca

The JSON importer doesn't merge the records in case they already exist.

To reproduce execute:

import database emp.json with mapping = {
    "Users": [{
        "@cat": "v",
        "@type": "User",
        "@id": "id",
        "@idType": "string",
        "@strategy": "merge",
        "EmployeeID": "@ignore",
        "ManagerID":  {
            "@cat": "e",
            "@type": "HAS_MANAGER",
            "@in": {
                "@cat": "v",
                "@type": "User",
                "@id": "id",
                "@idType": "string",
                "@strategy": "merge",
                "EmployeeID": "@ignore",
                "id": "<../ManagerID>"
            }
        }
    }]
}

Error:

Caused by: com.arcadedb.exception.DuplicatedKeyException: Duplicated key [1234] found on index 'User[id]' already assigned to record #7:0

        at com.arcadedb.database.TransactionIndexContext.checkUniqueIndexKeys(TransactionIndexContext.java:344)

        at com.arcadedb.database.TransactionIndexContext.checkUniqueIndexKeys(TransactionIndexContext.java:379)

        at com.arcadedb.database.TransactionIndexContext.commit(TransactionIndexContext.java:161)

        at com.arcadedb.database.TransactionContext.commit1stPhase(TransactionContext.java:569)

        at com.arcadedb.database.TransactionContext.commit(TransactionContext.java:121)

        at com.arcadedb.database.LocalDatabase.lambda$commit$2(LocalDatabase.java:397)

        at com.arcadedb.database.LocalDatabase.executeInReadLock(LocalDatabase.java:1415)

        at com.arcadedb.database.LocalDatabase.commit(LocalDatabase.java:392)

        at com.arcadedb.integration.importer.format.JSONImporterFormat.parseRecords(JSONImporterFormat.java:142)

        at com.arcadedb.integration.importer.format.JSONImporterFormat.load(JSONImporterFormat.java:95)

        at com.arcadedb.integration.importer.Importer.loadFromSource(Importer.java:107)

        at com.arcadedb.integration.importer.Importer.load(Importer.java:54)

Dataset:

{
  "Users":[
    {
      "id": "1",
      "EmployeeID":"1234",
      "Name":"Marcus"
    },
    {
      "id": "2",
      "EmployeeID":"1230",
      "ManagerID":"1234",
      "Name":"Win"
    },
    {
      "id": "3",
      "EmployeeID":"1232",
      "ManagerID":"1234",
      "Name":"Dave"
    }
  ]
} 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions