79728505

Date: 2025-08-07 11:40:09
Score: 0.5
Natty:
Report link

MikroORM creates business_biz_reg_no instead of using your biz_reg_no column for the join. You defined both biz_reg_no (a string) and a @ManyToOne() relation without telling MikroORM to reuse the same column.

@ManyToOne(() => BusinessEntity, {
  referenceColumnName: 'biz_reg_no',
  fieldName: 'biz_reg_no', //<= use this to force MikroORM to use the right column
  nullable: true,
})
business?: BusinessEntity;

Also fix this (array not single):

@OneToMany(() => InquiryEntity, (inquiry) => inquiry.business)
inquiries: InquiryEntity[]; // <= not `inquiry`

Now MikroORM will generate:

ON i.biz_reg_no = b.biz_reg_no

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ManyToOne
  • Low reputation (0.5):
Posted by: gdoura mohamed