Select @RelationId() - column not found
See original GitHub issueIssue type:
[ ] question [x] 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:
@Entity({ schema: 'public' })
export class OAuthCode {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(type => OAuthClient)
@JoinColumn({ name: 'client_id', referencedColumnName: 'clientId' })
client: OAuthClient;
@RelationId((code: OAuthCode) => code.client)
clientId: string;
}
@Entity({ schema: 'public' })
export class OAuthClient {
@PrimaryGeneratedColumn()
id: number;
@Index({ unique: true })
@Column()
clientId: string;
}
If i try to select explicitly relation id field like :
const oauthCode: OAuthCode = await this.codeRepository.findOne({
select: [
'clientId',
]
where: {
code: requestCode,
},
});
I got
{
"code": 503,
"inner": {},
"message": "clientId column was not found in the OAuthCode entity.",
"name": "server_error",
"status": 503,
"statusCode": 503
}
Why it’s not possible to select @RelationId()
like regular @Column() ?
Thanks !
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
TypeORM One-To-One Relation: Entity column not found ...
My postgreSQL DB contains three Entities: @Entity() export class User { constructor(email: string, ...
Read more >docs/decorator-reference.md | typeorm@v0.2.23-rc10
When set to false , the column data will not show with a standard query. By default column is select: true; default: string...
Read more >PostgreSQL and typeorm - Relational data
Tip: Setting relationships with relation id. If you have created the join id column on your entities, you can use this to set...
Read more >TypeORM - Relations
import {Entity, PrimaryGeneratedColumn, Column} from "typeorm"; @Entity() ... @JoinColumn() contain a “relation id” and foreign key to Customer table.
Read more >Relations | TypeORM Docs
What are relations; Relation options; Cascades; @JoinColumn options ... nullable: boolean - Indicates whether this relation's column is nullable or not.
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 Free
Top 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
Not working, is it going to be fixed? Please…
same old issue https://github.com/typeorm/typeorm/issues/1795