.findOne(undefined) returns first item in the database instead of undefined
Problem
Issue type: [ ] question [x] bug report [ ] feature request [ ] documentation issue Database system/driver: [ ] `cordova` [ ] `mongodb` [ ] `mssql` [ ] `mysql` / `mariadb` [ ] `oracle` [x ] `postgres` [ ] `sqlite` [ ] `sqljs` [ ] `react-native` [ ] `expo` TypeORM version: [x] `latest` [ ] `@next` [ ] `0.x.x` (or put your version here) Steps to reproduce or a small repository showing the problem: [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: .findOne(undefined) returns first item in the database instead of undefined
> But there are no conditions (`undefined`) and I think if there is no condition we have to return first entity like from `User.findOne({});` No, you except same behavior as SQL [code block] return empty row not first entity.
Trust Score
8 verifications
- 1
> But there are no conditions (`undefined`) and I think if there is no condition
> But there are no conditions (`undefined`) and I think if there is no condition we have to return first entity like from `User.findOne({});`
- 2
No, you except same behavior as SQL
[code block] return empty row not first entity.
Validation
Resolved in typeorm/typeorm GitHub issue #2500. Community reactions: 51 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep