V8-archive: Issue with file on o2m relationships

Created on 29 Aug 2019  Â·  5Comments  Â·  Source: directus/v8-archive

Steps to Reproduce

Screenrecording of what happened

artist one-to-many with artworks one-to-many with images

images collection contains file field

  • Add artworks item with images
  • Add artist with newly created artwork

Expected Behavior

The artwork added in artist should be saved successfully

Actual Behavior

The artwork is not saved

Other Context & Screenshots

Screenrecording of overall steps using the demo

Technical Details

  • Device: Desktop
  • OS: Win 10 10.0.18362.145
  • Web Server: Apache/2.4.29
  • PHP Version: PHP 7.1.30
  • Database: 10.2.26
  • Install Method: v2.5.0 build
  • Directus App: 7.10.0
app

Most helpful comment

@benhaynes @rijkvanzanten

This issue occurs as Select Existing passing whole object instead of PK for O2M.

image

This issue does not occur when file is not stored in the artwork cause of recursive relation as shown in the above screenshot (image contains artwork object too.).

We have a feature request to handle recursive relational data but for now, It seems like we should restrict the whole object to pass as payload as O2M and M2M for Select Existing from APP.

Let me know your thoughts.

All 5 comments

@benhaynes @rijkvanzanten

This issue occurs as Select Existing passing whole object instead of PK for O2M.

image

This issue does not occur when file is not stored in the artwork cause of recursive relation as shown in the above screenshot (image contains artwork object too.).

We have a feature request to handle recursive relational data but for now, It seems like we should restrict the whole object to pass as payload as O2M and M2M for Select Existing from APP.

Let me know your thoughts.

Thanks Binal — I defer to @rijkvanzanten on this one. :)

@rijkvanzanten - 🔔

The o2m doesn't diff nested objects, so it's not smart enough about filtering out what information to send about the file to the API

@benhaynes @rijkvanzanten @bjgajjar this is not only happening for files, but for any relationship where the target has any other relationship, when selecting.

Simple test case

Parent/Child:

  • Create two collections – Parent, Child
  • Add a M2O / O2M between them
  • Everything works perfectly fine, able to select child from parent, and vice versa

Child/Grandchild:

  • Create another collection – Grandchild
  • Add a M2O/O2M between Child and Grandchild
  • Everything works perfectly fine, able to select grandchildren from children, and vice versa

Happy path:

  • Try selecting a child which has no grandchild to the parent
  • Works perfectly fine

Bug

  • Try selecting a child which has a grandchild to the parent
  • Fails! Cannot be added!
  • What's more confusing is, it says Saved successfully, but if you open the record again, you'll find child was not saved at all

This affects pretty much every O2M where the destination has any other relationship. Bug severity _might_ be larger, because pretty much a lot of setups have multiple O2M relationships, and it's really hard to restrict every collection to have only one single relational field, and given that the success message can also mislead people into moving on and thinking everything is fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rijkvanzanten picture rijkvanzanten  Â·  3Comments

cdwmhcc picture cdwmhcc  Â·  3Comments

maettyhawk picture maettyhawk  Â·  3Comments

cdwmhcc picture cdwmhcc  Â·  3Comments

HashemKhalifa picture HashemKhalifa  Â·  3Comments