-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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: return 'null' (instead of 'undefined') on lazy relations that have no results #7147
fix: return 'null' (instead of 'undefined') on lazy relations that have no results #7147
Conversation
f22b01d
to
53ef708
Compare
…ve no results (typeorm#7146) Fix an issue where a lazy relation returns a Promise that resolves to 'undefined'. As implied by documentation, if the database has a NULL or no results, the result should be a literal 'null' in Javascript. Also added units tests to hilight the three scenarios in which this occurred. Closes typeorm#7146
53ef708
to
e98f4f0
Compare
Prior to applying the fix, here's what my unit tests showed:
After applying the fix:
|
Seems reasonable. Thank you for contribution! |
I think that was the first time I've created a Pull Request on an open-source project, complete with unit tests, and had it accepted. Thank you for the experience! |
This issue still occurs when you retrieve a newly created item via |
Did this PR introduce the bug #8582? |
* typeorm-0.2.30: (212 commits) version bump docs: fix javascript usage examples (typeorm#7031) fix: resolve migration for UpdateDateColumn without ON UPDATE clause (typeorm#7057) fix: Error when sorting by an embedded entity while using join and skip/take (typeorm#7082) fix: resolves Postgres sequence identifier length error (typeorm#7115) feat: closure table custom naming (typeorm#7120) feat: relations: Orphaned row action (typeorm#7105) docs: fix invalid code block in "find many options" (typeorm#7268) docs: Embodying the example (typeorm#7116) docs: document withDeleted option (typeorm#7132) fix: return 'null' (instead of 'undefined') on lazy relations that have no results (typeorm#7146) (typeorm#7147) docs: update cascade options (typeorm#7140) docs: add .ts to supported ormconfig formats (typeorm#7139) fix: improve stack traces when using persist executor (typeorm#7218) refactor: remove Oracle multirow insert workaround (since typeorm#6927) (typeorm#7083) feat: add NOWAIT and SKIP LOCKED lock support for MySQL (typeorm#7236) docs: update OneToMany grammar (typeorm#7252) feat: JavaScript file migrations output (typeorm#7253) docs: update Repository.ts (typeorm#7254) chore: update dependency cli-highlight to v2.1.10 (typeorm#7265) ...
Description of change
Fix an issue where a lazy relation returns a Promise that resolves to 'undefined'. As implied by
documentation, if the database has a NULL or no results, the result should be a literal 'null'
in Javascript. Also added units tests to hilight the three scenarios in which this occurred.
This PR is to fix reported issue #7146.
Pull-Request Checklist
master
branchnpm run lint
passes with this changenpm run test
passes with this changeFixes #0000