fix according to move to postgres

This commit is contained in:
Julian Krauser 2025-06-08 08:02:07 +02:00
parent f11ed83afc
commit aeb1ccbc42

View file

@ -1,7 +1,6 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source";
import { inspectionPlan } from "../../../entity/unit/inspection/inspectionPlan";
import { DB_TYPE } from "../../../env.defaults";
import DatabaseActionException from "../../../exceptions/databaseActionException";
export default abstract class InspectionPlanService {
@ -13,9 +12,7 @@ export default abstract class InspectionPlanService {
"inspectionPlan.latestVersionedPlan",
"inspectionPlan.versionedPlans",
"latestVersionedPlan",
DB_TYPE == "postgres"
? 'latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX("ivp"."createdAt") FROM "inspection_versioned_plan" "ivp" WHERE "ivp"."inspectionPlanId" = "inspectionPlan"."id")'
: "latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX(ivp.createdAt) FROM inspection_versioned_plan ivp WHERE ivp.inspectionPlanId = inspectionPlan.id)"
'latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX("ivp"."createdAt") FROM "inspection_versioned_plan" "ivp" WHERE "ivp"."inspectionPlanId" = "inspectionPlan"."id")'
)
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspectionPlan.equipmentType", "equipmentType")