Could not find any entity of type <Entity> when using specific commands.
See original GitHub issueIssue Description
Queries work when I use either QueryBuilder or Raw SQL, using find, findOne, getOne etc returns nothing.
Expected Behavior
The any query created with the following would return the expected user:
await db.getRepository<User>('User').findOneOrFail({ emailAddress });
// return
User {
firstName 'Foo',
lastName: 'Bar',
emailAddress: 'foo@bar.com'
}
Actual Behavior
await db.getRepository<User>('User').findOneOrFail({ emailAddress });
// "Could not find any entity of type \"User\" matching: {\n \"emailAddress\": \"foo@bar.com\"\n}"
await db.getRepository<User>('User').createQueryBuilder()
.where('emailAddress = :emailAddress', { emailAddress: `${emailAddress}` })
.getOne();
// returns undefined
await db.getRepository<User>('User').createQueryBuilder()
.where('emailAddress = :emailAddress', { emailAddress: `${emailAddress}` })
.execute();
// works
Steps to Reproduce
Code was working fine locally and deployed, before completing a new deployment. Upon completing a new deployment (none of the above code was changed), the error began appearing. The error transferred to my local environment when I performed a fresh node_modules install (It was not happening until that happened, regardless of the status of the deployed version).
- Calling any find/findOne/getOne/findOneOrFail command reproduces the issue
@Entity('user')
export class User {
@PrimaryGeneratedColumn()
userId: number;
@Column({ type: 'varchar', unique: true, length: 255 })
emailAddress: string;
@Column({ type: 'varchar', default: '' })
phoneNumber: string;
@Column({ type: 'varchar', default: '' })
title: string;
@Column('text')
preferredName: string;
@Column('text')
firstName: string;
@Column('text')
lastName: string;
@Column({ type: 'varchar', default: '' })
profilePhotoURL: string;
@Column('text')
accountType: string;
}
export const getUserQuery = async (emailAddress: string) => {
const db = await initDb(`${process.env.NODE_ENV}-db`); // Even hard-coding the selected DB makes no impact, have checked that.
return db.getRepository(User).findOneOrFail({ emailAddress });
My Environment
Dependency | Version |
---|---|
Operating System | Ubuntu 20.04 |
Node.js version | v12.16.3 |
Typescript version | 3.9.10 |
TypeORM version | 0.2.36 |
Additional Context
Relevant Database Driver(s)
DB Type | Reproducible |
---|---|
aurora-data-api |
yes |
aurora-data-api-pg |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
no |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✅ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✅ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
TypeORM cannot find entities if entity directory was not set in ...
My Entities files are stored on the ./src/bar/entity directory. I always get the following error: RepositoryNotFoundError: No repository for " ...
Read more >What's New in EF Core 7.0 - Microsoft Learn
Many entities can be updated with a single command and the entities are not loaded into memory, which means this can result in...
Read more >CrudRepository (Spring Data Core 3.0.0 API)
Returns all instances of the type T with the given IDs. If some or all ids are not found, no entities are returned...
Read more >Querying data via the DbSet - Learn Entity Framework Core
The DbSet represents a collection of entities of a specific type - the type specified by the type parameter. Queries are specified using...
Read more >Target selectors - Minecraft Wiki - Fandom
Bedrock Edition can use @r to target non-player entities via the type selector ... It does not target anything if the command was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using Postgres and I’m having the same problem.
The original issue is still a problem even with latest versions