Within the context of this repo run the following:
npm install
docker compose up -d database
npm run build
npm run database:migrate
npm run create-user
npm showcase-bug
create-user
will create a single user in the database outside of the actual test script to simulate an existing user.
showcase-bug
will:
- fork the em
- find an existing user
- create a new user profile with a reference to the user assigned to it's
user
field - flush the em.
- load the user again and populate the user profile relation
The expected behavior is that after step 4 one query is executed to store the new user profile, while another query is executed to write the new user profile id to the user's user_profile_id
column.
Instead of the above, we observe that after step 4 one query is executed to write the user profile. Then another query to update the user is executed, but it does not write the user profile id to the record. This leaves us with a broken relation through reverse assigning.
There is workaround in workaround.ts
, which can be executed using npm run showcase-workaround
.
Within test runs the combination of npm run clear-database && npm run create-user
can be used to reset the database state.