From 127ff8cf845dd0dc7ac7d8a840c0548fbf6336a6 Mon Sep 17 00:00:00 2001 From: Sheel Prabhakar Date: Sat, 29 Jun 2024 07:50:41 +0530 Subject: [PATCH] Add DatabaseType POSTGRES for the product name EnterpriseDB Resolves #4627 --- .../org/springframework/batch/support/DatabaseType.java | 5 ++++- .../springframework/batch/support/DatabaseTypeTests.java | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java index c4086b4539..d727cdc3cc 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DatabaseType.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,6 +103,9 @@ else if (databaseProductName.contains("AS") && (databaseProductVersion.startsWit databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName); } } + else if (StringUtils.hasText(databaseProductName) && databaseProductName.startsWith("EnterpriseDB")) { + databaseProductName = "PostgreSQL"; + } else { databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTests.java index 9c786e8310..2374153b3b 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,6 +138,12 @@ void testFromMetaDataForPostgres() throws Exception { assertEquals(POSTGRES, DatabaseType.fromMetaData(ds)); } + @Test + void testFromMetaDataForEnterpriseDB() throws Exception { + DataSource ds = DatabaseTypeTestUtils.getMockDataSource("EnterpriseDB"); + assertEquals(POSTGRES, DatabaseType.fromMetaData(ds)); + } + @Test void testFromMetaDataForSybase() throws Exception { DataSource ds = DatabaseTypeTestUtils.getMockDataSource("Adaptive Server Enterprise");