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

findOneOptions does not enforce requiring a where clause #9755

Open
nyxtom opened this issue Feb 3, 2023 · 0 comments
Open

findOneOptions does not enforce requiring a where clause #9755

nyxtom opened this issue Feb 3, 2023 · 0 comments

Comments

@nyxtom
Copy link

nyxtom commented Feb 3, 2023

Issue description

findOne throws an error if where clauses are not included yet FindOneOptions does not enforce this

Expected Behavior

Due to this change https://github.com/typeorm/typeorm/blob/master/src/entity-manager/EntityManager.ts#L1116-L1120 it would only make sense to have FindOneOptions also enforce the where clause. Otherwise, this part of the code should be reverted.

Actual Behavior

This error is only thrown at runtime, making it difficult to track down when FindOneOptions might be adjusted to be fixed for this.

Steps to reproduce

Create a query using FindOne without a where clause, typescript compiler will not pick this up due to the optional where parameter

My Environment

| Dependency | Version |
| Node.js version | v16.17.0 |
| Typescript version | 4.8.4 |
| TypeORM version | 0.3.11 |

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

1 participant