-
-
Notifications
You must be signed in to change notification settings - Fork 572
Open
Description
Hello, i'm new on nestjs,
i have an issue with the join of these two entities, can't find why...
any help ?..
Controller
@Crud({
model: {
type: Housekeeper,
},
query: {
join: {
geozones: {
alias: "test",
allow: ["postalCode"],
eager: true,
},
},
},
})
@ApiTags("housekeepers")
@Controller("housekeepers")
export class HousekeepersController implements CrudController<Housekeeper> {Geozone.ts
@Entity()
export class Geozone extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@IsDefined()
@Validate(RelationExists, [{ targetEntity: "housekeeper", targetField: "id" }])
@ApiProperty({ type: "number" })
@ManyToOne(() => Housekeeper, (hs) => hs.geozones)
@JoinColumn()
owner: Housekeeper;
@ApiProperty()
@Column()
postalCode: string;
}Housekeeper.ts
@Entity()
export class Housekeeper extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@ApiProperty()
@IsEmail()
@Column({ unique: true })
email: string;
@OneToMany(() => Geozone, (geozone) => geozone.owner)
geozones: Geozone[];
}Here is the error:
backend_1 | [Nest] 2197 - 04/16/2022, 6:27:43 PM LOG [NestApplication] Nest application successfully started +1ms
backend_1 | [Nest] 2197 - 04/16/2022, 6:28:24 PM ERROR [ExceptionsHandler] Duplicate column name 'Housekeeper_id'
backend_1 | QueryFailedError: Duplicate column name 'Housekeeper_id'
backend_1 | at Query.onResult (/usr/src/app/src/driver/mysql/MysqlQueryRunner.ts:222:33)
backend_1 | at Query.execute (/usr/src/app/node_modules/mysql2/lib/commands/command.js:36:14)
backend_1 | at PoolConnection.handlePacket (/usr/src/app/node_modules/mysql2/lib/connection.js:456:32)
backend_1 | at PacketParser.onPacket (/usr/src/app/node_modules/mysql2/lib/connection.js:85:12)
backend_1 | at PacketParser.executeStart (/usr/src/app/node_modules/mysql2/lib/packet_parser.js:75:16)
backend_1 | at Socket.<anonymous> (/usr/src/app/node_modules/mysql2/lib/connection.js:92:25)
backend_1 | at Socket.emit (node:events:390:28)
backend_1 | at addChunk (node:internal/streams/readable:315:12)
backend_1 | at readableAddChunk (node:internal/streams/readable:289:9)
backend_1 | at Socket.Readable.push (node:internal/streams/readable:228:10)
update:
i found that this issue appears only when "limit" or "maxLimit" is set in query.
Gustavo-Contreiras-Hotels-at-Home, ghostlexly, zetti-caletti and MaxZhurin
Metadata
Metadata
Assignees
Labels
No labels