Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Importer does not use the merge strategy #1492

Closed
lvca opened this issue Mar 1, 2024 · 0 comments
Closed

JSON Importer does not use the merge strategy #1492

lvca opened this issue Mar 1, 2024 · 0 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@lvca
Copy link
Contributor

lvca commented Mar 1, 2024

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"
    }
  ]
} 
@lvca lvca self-assigned this Mar 1, 2024
@lvca lvca added bug Something isn't working in progress The team is actively working on this issue labels Mar 1, 2024
lvca added a commit that referenced this issue Mar 1, 2024
@lvca lvca added this to the 24.2.1 milestone Mar 1, 2024
@lvca lvca closed this as completed Mar 1, 2024
@lvca lvca added fixed and removed in progress The team is actively working on this issue labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

1 participant