Uploaded image for project: 'ui-inventory'
  1. ui-inventory
  2. UIIN-1546

Inventory: Can not link multiple childs to the same parent

    XMLWordPrintable

Details

    • Prokopovych - Sprint 118
    • 3
    • Prokopovych
    • R2 2021 Bugfix
    • GBV

    Description

      Tested on https://folio-snapshot.dev.folio.org/ on 2021-06-30, and 2021-07-01:
       
      1. Go to Inventory and create a new instance record
      2. Enter minimal metadata: Resource title: "Volume 1980", Resource type: "text"
      3. Scroll down to the Instance relationship accordion
      4. Click "Add parent instance", click the plus icon, search for "aba" and click on the result in the list
      5. Select "monographic series" as type of relation
      6. Click "Save and close".  The instance record is saved and the relation is established.
      7. Repeat steps 1-5, but use "Volume 1981" as resource title in step 2
      8. Click "Save and close"
       
      Expected result:
      The instance is saved and the relationship is established.
       
      Actual result:
      An error message is displayed:

      ERROR: in module @folio/inventory, operation POST on resource 'records' failed, saying: id value already exists in table instance_relationship: 69640328-788e-43fc-9c3c-af39e243f3b7

      If you dismiss the error message and click "Save and close" again, the same message appears. Now click "Cancel" and do a search on "volume 1981" in the Instance keyword index. The instance record has been created multiple times, although the user exited the screen via the "Cancel" button. On both records the relation is not present.

      Cause of the problem:

      Each relationship that is created between two instances is assigned a unique ID, a UUID in the property "id" of the relationship object. This ID is needed in order to later find and update/PUT the relation by ID. 

      When creating a new relation, the UI does not have to provide this ID, mod-inventory will generate a new UUID for the new relation.  IF the UI provides it for a new relation to be created, the UI must itself ensure that it's unique; the best would probably be to leave it out. 

      However, the most recent UI logic pushes an entire instance object to the back-end for the new relation, and since an instance object has its own "id" property, the instance id will thus become the relationship's id as well. This means, you can only ever add a given instance as a parent or child of any other instances once. The next time you try to add the same parent to another instance it will fail with a unique constraint failure. See comment  https://issues.folio.org/browse/UIIN-1546?focusedCommentId=106757&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-106757  for details about the exact properties that are pushed, what (few) properties that are actually needed, and the offending "id" property.  

      TestRail: Results

        Attachments

          1. image-2021-08-01-15-05-58-320.png
            64 kB
            Felix Hemme
          2. image-2021-08-01-15-07-03-428.png
            159 kB
            Felix Hemme
          3. instance-creation.mp4
            9.26 MB
            Felix Hemme
          4. Screenshot from 2021-06-30 19-31-44.png
            261 kB
            Niels Erik Gilvad Nielsen
          5. Skärmavbild 2021-07-14 kl. 11.59.27.png
            146 kB
            Charlotte Whitt
          6. Skärmavbild 2021-07-19 kl. 12.59.30.png
            141 kB
            Charlotte Whitt

          Issue Links

            Activity

              People

                mpk35 Michal Kuklis
                fhemme Felix Hemme
                Charlotte Whitt Charlotte Whitt
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases