question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot get entity metadata for the given alias

See original GitHub issue

Issue type:

[x] question [ ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x] postgres [ ] cockroachdb [ ] 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: Hi. I’m having an issue with retrieving documents from a nested FROM-clause like this:

let query = getConnection().createQueryBuilder()
            .from((qb) => {
                    return qb
                        .from(A, "a")
                        .limit(1);
                }
                , "alias")

And get the error Cannot get entity metadata for the given alias "alias". Also, if I try to add another from:

.from(A, "b")

the query works, but the second FROM doesn’t replace the first one, as specified in the docs. How can I do this the right way? Thanks

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:73
  • Comments:40 (2 by maintainers)

github_iconTop GitHub Comments

22reactions
volovodenkocommented, Feb 18, 2020

Works only with getRawMany()

11reactions
goobetcommented, Sep 11, 2020

Try this hack:

  query.expressionMap.mainAlias.metadata = query.connection.getMetadata(YourEntity)

Hope it will help someone

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeORM SQL SubQuery - Stack Overflow
And I'm getting this error : Cannot get entity metadata for the given alias "foo". Cannot figure out why. javascript · sql ·...
Read more >
typeorm/typeorm - Gitter
I feel like I'm close but I get the error: TypeORM connection error: Error: Entity metadata for Toy#creator was not found. Check if...
Read more >
Entity metadata was not found
EntityMetadataNotFound error is displayed when TypeORM cant find your entities. Often this is caused by wrong/misspelled entry in your ormconfig file. Often ...
Read more >
TypeORM - No metadata for "User" was found. - Reddit
For context, I am using typescript (sorry should have posted that). On this, for typeORM in the `ormconfig.json` should the `entities` point to ......
Read more >
Select using Query Builder | TypeORM Docs
Most of the time, you need to select real entities from your database, ... In this SQL query, users is the table name,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found