Correct me, if i am wrong, but:
After a quick peek into the code i see this (and its consequences) is wrong:

        $type = $field['cardinality'] == 1 ? $entity_type : 'list<' . $entity_type . '>';

The backreference is always a list (has multiple cardinality, even if the original field has cardinaltiy 1.
(YOu can always have multiple (maybe single)references to an entity.)

Comments

jantoine’s picture

Status: Active » Needs review
StatusFileSize
new2.58 KB

@alex-rutz,

No, I believe you are correct. A cardinality setting allowing multiple values for a field creates a many to many relationship. That in reverse is still many to many (more than one).

A cardinality setting allowing a single value creates a many to one relationship. That in reverse is one to many, so from one node we should be able to retrieve many.

An example:
Content type Product has a single cardinality reference field to content type Company. Create Company A, Product B referencing Company A and Product C referencing Company A. Although Product B and Product C can only reference a single Company (A), Company A has multiple products referencing it (B and C).

Attached is a patch that reverses that last commit that broke this.

geek-merlin’s picture

Code looks exactly like i imagined.
Will test as i come to it...

jsacksick’s picture

Status: Needs review » Fixed

Committed.

  • jsacksick committed bc86616 on 7.x-1.x authored by jantoine
    Issue #2402029 by jantoine: Cardinality flawed, must be always multiple
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.