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

Undefined entity - in subscribers after and before update events #2809

Closed
darekf77 opened this issue Sep 16, 2018 · 5 comments
Closed

Undefined entity - in subscribers after and before update events #2809

darekf77 opened this issue Sep 16, 2018 · 5 comments

Comments

@darekf77
Copy link

darekf77 commented Sep 16, 2018

Issue type:

[x ] bug report
Database system/driver:

[x] sqlite

TypeORM version:

[ x] `0.2.7

Steps to reproduce or a small repository showing the problem:

Simple example here: https://github.com/darekf77/typeorm-sqlite-error-example

@ChangJoo-Park
Copy link
Contributor

+1 here
same environment.

@VinceOPS
Copy link
Contributor

VinceOPS commented Dec 10, 2018

Same here - PostgreSQL & TypeORM 0.2.8 - looks like this is "by design"... The UpdateQueryBuilder is not passing any argument for entity or databaseEntity to the method responsible for broadcasting Events...

Btw I think there is a mistake in the definition of UpdateEvent as entity and databaseEntity should be optional (entity?: <type> instead of entity: <type>)

Related to #2246 (contains answers from Pleerock).
What could be possible is to pass the "valuesSet" from UpdateQueryBuilder, but this isn't the entity, properly speaking.

@pleerock
Copy link
Member

pleerock commented Jan 7, 2019

its not a bug. I told it probably hundred of times probably that people should use save if they want to have all orm functionality. update was supposed as "just execute update query and thats it" - limited functionality with maximal performance. Maximal performance means no additional selects, no additional selects means no databaseEntity set in subscriber event.

@VinceOPS yes we can update signature. Feel free to pr ;)

@pleerock pleerock closed this as completed Jan 7, 2019
@dhammma
Copy link

dhammma commented Jul 23, 2020

This behavior very not obvious for me

@rskvazh
Copy link

rskvazh commented Aug 14, 2020

This is definitely a bug that event.entity typed as always not undefined, but SOMETIMES its undefined.
Why you are calling subscribers/listeners for this situation at all (when update/increment without save())?
I've a bug because this is not obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants