-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Closed
Copy link
Labels
Description
Issue Description
When trying to orderBy a column of an embedded entity the query fails while using take/skip and joining another.
const result = await postRepo.createQueryBuilder("post")
.leftJoinAndSelect("post.user", "user")
.orderBy("post.blog.date")
.take(2)
.skip(1)
.getMany();
Expected Behavior
It should be possible to sort by properties in embedded entities.
Actual Behavior
Error Message:
TypeError: Cannot read property 'databaseName' of undefined
at /home/h4kor/code/ajai/typeorm/src/query-builder/SelectQueryBuilder.ts:2013:145
Steps to Reproduce
I will provide an Pull Request shortly.
Use the query above and executed with the entities below.
Entities:
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "../../../src";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(
() => Post,
(post) => post.user,
)
posts: Post[];
}
export class PublishInfo {
@Column({ nullable: true })
date: Date;
}
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;
@Column()
text: string;
@Column(_type => PublishInfo)
blog: PublishInfo;
@Column(_type => PublishInfo)
newsletter: PublishInfo;
@ManyToOne(
() => User,
(user) => user.posts,
)
user: User
}
My Environment
| Dependency | Version |
|---|---|
| Operating System | |
| Node.js version | v12.16.2 |
| Typescript version | 3.6.0 |
| TypeORM version | 0.2.29 (master) |
Additional Context
Relevant Database Driver(s)
-
aurora-data-api -
aurora-data-api-pg -
better-sqlite3 -
cockroachdb -
cordova -
expo -
mongodb -
mysql -
nativescript -
oracle -
postgres -
react-native -
sap -
sqlite -
sqlite-abstract -
sqljs -
sqlserver
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, although I believe I could do it if I had the time...
- No, I don't have the time and I wouldn't even know how to start.