Hi,
We are having issues setting models with a composite primary key and accessing these through related data.
This is one of the models we are having a problem on, in the db we have this index "enterprise_groups_accounts_pkey" PRIMARY KEY, btree (enterprise_group_id, account_id)
:
At this point, all good we can access the Enterprise Groups Accounts
table
The problem comes when set a simple hasMany on a related table, as such on the accounts model:
this.hasMany(models.enterprise_groups_accounts, {
foreignKey: 'account_id'
})
Expected behavior
We should be able to access to account enterprise groups account from the account table
Actual behavior
Cannot reach your data
Error
More precisely this error in the console:
When investing I realized that recordSerializer.serialize(data)
will not set the id properly.
From the types defined I am supposed to expect data looking like this:
StatSerialized.data: {
type: string;
id: string;
attributes: {
value: any[];
};
}
But here we do not have an id field.
Context
- Package Version: 6.3.6
- Express Version: “forest-express-sequelize”: “^7.8.0”,
- Sequelize Version: “sequelize”: “~5.15.1”
- Database Dialect: postgresql
- Project Name: Commutifi