LaWebcapsule / directus9

directus9 - openSource maintenance of directus
GNU General Public License v3.0
71 stars 9 forks source link

Count doesn't work as expected on relations. #22

Closed adussarps closed 1 year ago

adussarps commented 1 year ago

Describe the Bug

Count is not working as expected for relations.

Capture d’écran 2023-06-23 à 17 02 36

Count is only able to count items in arrays.

However, the create/update payload for relational fields isn't an array, but a complex object (see below) which cause "validation" and probably other checks to fail.

Note: example of the current payload on a nested collection update called 'approvals'

{
  "payload": {
    "approvals": {
      "create": [
        {
          "message": "<p>Another Approval</p>"
        }
      ],
      "update": [],
      "delete": []
    }
  },
  "event": "files.update",
  "keys": [
    "c7cb0a8f-6809-47a0-8086-d6d8a3a77b87"
  ],
  "collection": "directus_files"
}

To Reproduce

Create a validation rule using "count" for a relational field.

Directus Version

v9.26.3

Hosting Strategy

Self-Hosted (Custom)