New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order by joined column broken in Postgres #3736
Comments
Not really sure but I think you have to add relations: ["profile", "photos", "videos"] |
@frankdugan3 |
Did not solve the problem. The column does exist, and if I run the query with that line added, it works fine. I added that as a comment to help with fixing the issue. I did not try adding the |
@frankdugan3 Ok, back to the issue. I believe this is a bug but I cannot confirm or deny it unless I know exactly what is going on there. I really don't like that generated query. Could you please post your entity definition/make a reproduction repo/provide failing test? |
This is a summary of what the entities look like: @Entity()
export class Gage extends Node {
@Column({ unique: true, nullable: false, type: 'text' })
name!: string
// ...
// Relationships
@ManyToOne((type) => GageType, (type) => type.gages, {
cascade: true,
nullable: false,
lazy: true,
onDelete: 'RESTRICT',
onUpdate: 'CASCADE',
})
type!: Lazy<GageType>
// ...
} @Entity()
export class GageType extends Node {
@Column({ type: 'text', nullable: false, unique: true })
name!: string
// Relationships
@OneToMany((type) => Gage, (gage) => gage.type, { lazy: true })
gages!: Lazy<Gage[]>
} export abstract class Node extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
readonly id!: string
@CreateDateColumn()
createdAt!: Date
@UpdateDateColumn()
updatedAt!: Date
@VersionColumn({ comment: 'Count of updates to this row.' })
version!: number
} |
No updates on this? I'm with the same issue... |
…typeorm#8118)" This reverts commit 1649882.
typeorm#8352) * Revert "fix: ordering by joined columns for PostgreSQL (typeorm#3736) (typeorm#8118)" This reverts commit 1649882. * test: add a test for leftJoinAndSelect with ordering by a relation property and a limit (typeorm#8346)
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[x]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[ ]
latest
[x]
@next
[ ]
0.x.x
(or put your version here)When ordering by a nested column in Postgres, it would appear that the generated SQL is missing a select clause. I've included an example of the code and the generated SQL with error message and missing select. I am also using lazy loading (combined with TypeGraphQL) if that is a factor.
The text was updated successfully, but these errors were encountered: