Duplicate fields when the primary key is also a foreign key

Feature(s) impacted

In Forest Admin UI

  • Extra fields + misplaced fields when creating new object
  • Relationships are not properly linked in the “related data” column.

Schema

                       Table "codes"
   Column   |           Type           | Collation | Nullable | Default 
------------+--------------------------+-----------+----------+---------
 created_at | timestamp with time zone |           |          | now()
 code       | character varying        |           | not null | 
 ...        | character varying        |           | not null | 

Indexes:
    "codes_pkey" PRIMARY KEY, btree (code)
Referenced by:
    TABLE "A" CONSTRAINT "A_code_fkey" FOREIGN KEY (code) REFERENCES codes(code) ON UPDATE CASCADE
    TABLE "B" CONSTRAINT "B_code_fkey" FOREIGN KEY (code) REFERENCES codes(code) ON UPDATE CASCADE

                              Table "A"
          Column          |           Type           | Collation | Nullable | Default 
--------------------------+--------------------------+-----------+----------+---------
 created_at               | timestamp with time zone |           |          | now()
 code                     | character varying        |           | not null | 
 ...                      | character varying        |           | not null | 

Indexes:
    "A_pkey" PRIMARY KEY, btree (code)
Foreign-key constraints:
    "A_code_fkey" FOREIGN KEY (code) REFERENCES codes(code) ON UPDATE CASCADE

Observed behavior

When creating a new record in a table A (primary key = foreign key (primary key of codes) = ‘code’):

Problem 1:
When the user creates a new row in the table “A”, there are two fields for code:

  • One that is free form (I imagine because it’s the primary key)
  • One that is Code through code * (link to an existing code through code)

Problem 2:
When the user creates a new row in the table “codes”, there is an extra field: A: Link to an existing A

Expected behavior

Problem 1:
There is only one field code that is a scrollable / lookahead field.

Problem 2:
This field should not appear

Context

  • Project name: BDD DS
  • Team name: message me
  • Environment name: prod
  • Database type: postgres