Closed geoidesic closed 4 years ago
I tried to simplify this in order to remove some possible problems. Firstly, instead of a through table, I used a join table and removed the need for a role_id condition. So the schema for the join becomes this:
$this->table('enquiry_clients')
->addColumn('enquiry_id', 'uuid')
->addColumn('person_id', 'uuid')
->addColumn('role_id', 'integer', ['signed' => false, 'default' => 3])
->addColumn('created', 'datetime')
->addColumn('modified', 'datetime')
->create();
and the association like so:
$this->belongsToMany('Clients', ['joinTable' => 'enquiry_clients', 'className' => 'People', 'foreignKey' => 'enquiry_id', 'targetForeignKey' => 'person_id']);
The result is no different to the above – it still saves the association correctly but when retrieving the data via the relationships link it is exactly as shown n the OP.
The only notable difference is that now the other similar associations don't return the same data. E.g. the representatives
association, which now returns the following:
{
"links": {
"self": "/api/enquiries/2c1e6c31-6eba-4fa1-b066-8e203644b738/relationships/representatives",
"related": "/api/enquiries/2c1e6c31-6eba-4fa1-b066-8e203644b738/representatives"
},
"data": []
}
This is not a well described issue: this effectively describes a whole bunch of bugs, so I will close this and create new issues which isolate the bugs better.
I have the following route:
I have an
through
association defined onEnquiriesTable
:I've managed to get this association to correctly save a record to the
EnquiryContacts
table.However when I try to retrieve the associated records via the generated relationships URL:
The data I get back looks like this:
Which is not according to the JSON:API spec, I don't think. Also I get this same data back from other similar associations for which no records have been saved, so it is not respecting the
conditions
config option of the route when fetching data.