Feature(s) impacted
Relationship ID propagation in Forest Admin UI when the relationship uses the same column as both PK and FK.
Observed behavior
When creating a new record in a child table that has a relationship with a parent table (sharing the same ID):
- User creates new child record from the parent record details in edit mode (clicking “+”)
- On the child create page, linked id is correctly pre-filled
- But the ID field remains blank and required, without any autocomplete
- So the user has to copy the ID from the product (despite the linked id being already filled)
- This can be cumbersome, especially when the reference of the parent is something else than the id since the user has to come back etc
Expected behavior
When selecting the parent record in the relationship field, the ID field should automatically populate with the parent record’s UUID since they share the same ID in a one-to-one relationship. Or the ID field should not be visible since it’s essentially duplicated with the linked id field.
Context
Database schema:
CREATE TABLE parent (
id UUID PRIMARY KEY,
-- other fields
);
CREATE TABLE child (
id UUID PRIMARY KEY,
variant TEXT NOT NULL,
FOREIGN KEY (id) REFERENCES parent(id)
);
Model definitions:
// parent model
const Parent = sequelize.define('parent', {
id: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: Sequelize.literal('uuid_generate_v4()')
}
});
// child model
const Child = sequelize.define('child', {
id: {
type: DataTypes.UUID,
primaryKey: true,
allowNull: false
},
variant: {
type: DataTypes.TEXT,
allowNull: false
}
});
// Relationship
Child.belongsTo(Parent, {
foreignKey: {
name: 'idKey',
field: 'id'
},
as: 'linkedId'
});
- Project name: contact me
- Team name: contact me
- Environment name: Development / Staging / Production
{
“liana”: “forest-express-sequelize”,
“liana_version”: “9.4.1”,
“stack”: {
“database_type”: “postgres”,
“engine”: “nodejs”,
“engine_version”: “20.9.0”,
“orm_version”: “6.37.3”
}
}