My challenge involves managing this specific Entity
@Entity({ name: 'orders' })
export class Order {
...
@ManyToOne(() => BulkOrder, (bulkOrder) => bulkOrder.orders)
bulkOrder?: BulkOrder
}
In my update process, I am attempting to reset the relation to null
.createQueryBuilder()
.update(Order)
.set({ status: OrderStatus.OPEN, bulkOrder: undefined }).
where(...).execute()
However, it seems that the bulkOrder field is not being updated correctly, as indicated by the generated query
query: UPDATE "orders" SET "status" = $1, "updated_at" = CURRENT_TIMESTAMP WHERE ("id" IN ($2, $3) ...
Is there a way to successfully set the relation to null? While I understand I could manually set it to null and save the entity, using a query builder is necessary in order to avoid updating unintended records