Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent wrong returned entity in ReturningResultsEntityUpdator #6440

Merged

Conversation

imnotjames
Copy link
Contributor

in the ReturningResultsEntityUpdator we have to check that the entityId
we pull from the entity is actually there. if we don't we will create a
where clause that's undefined - effectively querying for every record
in the database and returning the wrong value

@imnotjames
Copy link
Contributor Author

imnotjames commented Jul 21, 2020

I should probably add a test that validates this - I found it via cascades causing some other bug..

Problem is - I'm not sure the best way to test this functionality..

This is kind of an edge case that breaks via various other situations.

in the `ReturningResultsEntityUpdator` we have to check that the `entityId`
we pull from the entity is actually there.  if we don't we will create a
where clause that's undefined - effectively querying for every record
in the database and returning the wrong value
@imnotjames imnotjames marked this pull request as draft July 21, 2020 17:50
@imnotjames imnotjames marked this pull request as ready for review July 22, 2020 01:10
@imnotjames imnotjames force-pushed the bugfix/returning-wrong-entity-after-insert branch from cacfd33 to 96405cd Compare July 22, 2020 01:10
@pleerock
Copy link
Member

The question is: do we need to return error or just skip setting returning result? We need to know a real-case scenario of how this could happen and why

@imnotjames
Copy link
Contributor Author

imnotjames commented Sep 26, 2020

At this moment it's a temporary defensive and preventative measure to throw an exception - preventing the incorrect return & invalid retrieval from the database.

There's underlying issues that cause this behavior that haven't been determined yet.

You can see this same technique is already used in the update method - https://github.com/typeorm/typeorm/pull/6440/files#diff-39f14c63414acd9b002e8d238893fa25L59

@pleerock pleerock merged commit c1c8e88 into typeorm:master Sep 29, 2020
zaro pushed a commit to zaro/typeorm that referenced this pull request Jan 12, 2021
…ypeorm#6440)

in the `ReturningResultsEntityUpdator` we have to check that the `entityId`
we pull from the entity is actually there.  if we don't we will create a
where clause that's undefined - effectively querying for every record
in the database and returning the wrong value
@imnotjames imnotjames deleted the bugfix/returning-wrong-entity-after-insert branch June 21, 2021 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants