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.

Cannot find alias for relation at user

See original GitHub issue

Issue Description

Cannot find alias for relation at user
      at _loop_3 (src/query-builder/QueryBuilder.ts:944:27)
      at UpdateQueryBuilder.Object.<anonymous>.QueryBuilder.findColumnsForPropertyPath (node_modules/typeorm/query-builder/QueryBuilder.js:817:27)
      at UpdateQueryBuilder.<anonymous> (src/query-builder/QueryBuilder.ts:1059:68)
      at step (node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
      at Object.next (node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
      at UpdateQueryBuilder.Object.<anonymous>.QueryBuilder.getWhereCondition (src/query-builder/QueryBuilder.ts:1195:80)
      at UpdateQueryBuilder.Object.<anonymous>.UpdateQueryBuilder.where (src/query-builder/UpdateQueryBuilder.ts:176:32)
      at EntityManager.Object.<anonymous>.EntityManager.update (src/entity-manager/EntityManager.ts:514

PR with test case: https://github.com/typeorm/typeorm/pull/8024

Expected Behavior

      await getRepository(WorkspaceMemberEntity).update(
        {
          user: {
            id: createdWorkspace.createdById!,
          },
          workspace: {
            id: createdWorkspace.id,
          },
        },
        {
          role: WorkspaceMemberRole.MEMBER,
        }
      );

It should update the table.

Actual Behavior

Error: Cannot find alias for relation at user.

My Environment

Dependency Version
Operating System Windows
Node.js version 14.16
Typescript version 4.3.5
TypeORM version ^0.2.36

Relevant Database Driver(s)

DB Type Reproducible
aurora-data-api no
aurora-data-api-pg no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres yes
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?

  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
botrecommented, Aug 4, 2021

I still need WorkspaceEntity, UserEntity, and BaseEntity to replicate this.

Alternatively, a test case that’s minimal & still exhibits this issue would be more helpful.

Is there a repository I can clone to easily set this up?

Edit: I have found the instructions at https://github.com/typeorm/typeorm/blob/master/DEVELOPER.md

0reactions
botrecommented, Aug 5, 2021

Hi,

I will be able to continue my investigation / tweak the test case to hopefully reproduce the issue starting next Tuesday.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find alias for relation at ... · Issue #8310 - GitHub
UPDATE: I was having the 'cannot find alias' error on the save method. The reason was that the ID I was providing in...
Read more >
typeorm "\"user\" alias was not found. Maybe you forgot to join ...
Try to add a condition to your join: .leftJoinAndSelect('user.avatar', 'avatar', 'avatar.id = user.avatarId'). or/and inverse side to the ...
Read more >
TypeORM: How to Use Column Alias when Querying Data
This succinct tutorial shows you how to use column aliases to assign temporary names to columns when selecting data with TypeORM.
Read more >
Query with distinct sort and column alias produces error ...
I'm trying to use sql query on azure-databricks with distinct sort and aliases. SELECT DISTINCT album.ArtistId AS my_alias; FROM album ORDER ...
Read more >
CREATE ALIAS statement - Progress Documentation
Also, if there are several connected databases, the application can ask the user which one to select, then set the alias accordingly. The...
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