From 4aea94ccb607bf3100f0f9f0f9db8ade5e1f9066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Primo=C5=BE=20Delopst?= Date: Tue, 24 Sep 2024 16:43:17 +0200 Subject: [PATCH] Fix forced ID migration for MSSQL (#6290) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Primož Delopst --- .../taskdef/ForceIdMigrationFixTask.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ForceIdMigrationFixTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ForceIdMigrationFixTask.java index 07607a90845..543fd942892 100644 --- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ForceIdMigrationFixTask.java +++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ForceIdMigrationFixTask.java @@ -89,7 +89,7 @@ public class ForceIdMigrationFixTask extends BaseTask { " set fhir_id = coalesce( " + // case 5. - " trim(fhir_id), " + trimFhirId() + // case 3 " (select f.forced_id from hfj_forced_id f where f.resource_pid = res_id), " @@ -109,6 +109,22 @@ public class ForceIdMigrationFixTask extends BaseTask { } } + private String trimFhirId() { + switch (getDriverType()) { + case MSSQL_2012: + return " LTRIM(RTRIM(fhir_id)), "; + case H2_EMBEDDED: + case DERBY_EMBEDDED: + case MARIADB_10_1: + case MYSQL_5_7: + case POSTGRES_9_4: + case ORACLE_12C: + case COCKROACHDB_21_1: + default: + return " trim(fhir_id), "; + } + } + private String getWhereClauseByDBType() { switch (getDriverType()) { case MSSQL_2012: