aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml2
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentUpdaterIT.java18
2 files changed, 19 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index 7f897a7090f..da43df99c77 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -39,7 +39,7 @@
SELECT
<include refid="componentColumns"/>
FROM components p
- inner join project_branches pb on pb.uuid = p.branch_uuid
+ left outer join project_branches pb on pb.uuid = p.branch_uuid
where
lower(p.kee)=lower(#{key,jdbcType=VARCHAR})
and <include refid="mainBranchOrPortfolio"/>
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentUpdaterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentUpdaterIT.java
index 2fff57a6f82..033a357fc1a 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentUpdaterIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentUpdaterIT.java
@@ -374,6 +374,24 @@ public class ComponentUpdaterIT {
.hasMessage("Could not create Project with key: \"%s\". A similar key already exists: \"%s, %s\"", newKey, existingKey, existingKeyLowerCase);
}
+ @Test
+ public void createComponent_shouldFail_whenCreatingComponentWithMultipleExistingPortfolioKeysButDifferentCase() {
+ String existingKey = randomAlphabetic(5).toUpperCase();
+ String existingKeyLowerCase = existingKey.toLowerCase();
+ db.components().insertPrivatePortfolio(portfolio -> portfolio.setKey(existingKey));
+ db.components().insertPrivatePortfolio(portfolio -> portfolio.setKey(existingKeyLowerCase));
+ String newKey = StringUtils.capitalize(existingKeyLowerCase);
+
+ NewComponent newComponent = NewComponent.newComponentBuilder()
+ .setKey(newKey)
+ .setName(DEFAULT_PROJECT_NAME)
+ .build();
+
+ DbSession dbSession = db.getSession();
+ assertThatThrownBy(() -> underTest.create(dbSession, newComponent, null, null))
+ .isInstanceOf(BadRequestException.class)
+ .hasMessage("Could not create Project with key: \"%s\". A similar key already exists: \"%s, %s\"", newKey, existingKey, existingKeyLowerCase);
+ }
@Test
public void create_createsComponentWithMasterBranchName() {