You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReturningResultsEntityUpdator assigning incorrect uuids to entities after upsert #10574
It assumes the results are returned in the order they were just inserted - which is not the case at least for Sql.js and SQLite that I have tested against (see screenshot below)
As a result when it loops the entities and tries to match the result set by index, the order of the arrays are different so it assigns the wrong uuid back to each entity.
Steps to reproduce
Have a simple table with uuid as a primary key.
Perform an upsert (on uuid) of several rows into this table.
After the upsert has been run, ReturningResultsEntityUpdator will try to fetch the uuids from the database for these newly updated/inserted rows
The query it builds will not have an order defined, so returned results will not match the order entities were upserted in.
Wrong uuid will be assigned back to the entity
My Environment
TypeOrm v0.3.17
Sql.js 1.8.0
Additional Context
Code in question that produces a result set from the database and assumes the entityIndex aligns in both the result and the entities array. This is not the case as the 2 arrays are ordered differently (at least for sql.js)
Comparing the first 5 items of both arrays shows different ordering - so matching by index in both arrays results in different UUIDs:
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).
As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.
🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.
Activity
BARNZ commentedon Dec 28, 2023
Potentially relates to #7094
I think this bug was introduced by this change: 4fc4a1b
The query needs to be ordered (somehow?) so that results can be looped over predictably
github-actions commentedon Sep 18, 2025
TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).
As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.
🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.