mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
change contrat creation
This commit is contained in:
@@ -5635,9 +5635,12 @@ export class TrainSchedulingService {
|
||||
// --- validate additions: AVAILABLE, loose, standing in the train's yard ---
|
||||
const added: Wagon[] = [];
|
||||
for (const wagonId of addWagonIds) {
|
||||
// No `relations` on this query: Postgres refuses FOR UPDATE through the
|
||||
// nullable side of the wagonType LEFT JOIN ("FOR UPDATE cannot be
|
||||
// applied to the nullable side of an outer join"). Lock the row alone,
|
||||
// then attach its type with a separate unlocked lookup.
|
||||
const wagon = await manager.getRepository(Wagon).findOne({
|
||||
where: { id: wagonId },
|
||||
relations: { wagonType: true },
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!wagon) throw new NotFoundException(`Wagon ${wagonId} not found`);
|
||||
@@ -5654,6 +5657,10 @@ export class TrainSchedulingService {
|
||||
`Wagon ${wagon.wagonNumber} is not in the train's yard — only wagons in the same yard can be coupled`,
|
||||
);
|
||||
}
|
||||
wagon.wagonType =
|
||||
(await manager
|
||||
.getRepository(WagonType)
|
||||
.findOne({ where: { id: wagon.wagonTypeId } })) ?? undefined;
|
||||
added.push(wagon);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user