Skip to content

typeorm findOneBy( { id: null or undefined } ) method return the first record on the table ! #9316

@haddadzineddine

Description

@haddadzineddine

Expected Behavior

Return null

Actual Behavior

Retrieve the first record from users table !

Example :

const user = await userRepository.findOneBy({
            id: undefined //  or `null`
        });

/*  

Result :

User {
  id:,
  username: ,
  ....
}

*/

Steps to Reproduce

  1. Create typeorm connection
  2. Create user entity and migrate it to the database
  3. Query the database using the user repository then call findOneBy method .

Relevant Database Driver(s)

DB Type Reproducible
sqlite yes

For other database drivers , i have no idea :)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions