diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2019-07-02 23:12:14 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-07-10 08:36:52 +0200 |
commit | 983f593231da12bd64d9df23c18d4f2c7aaa6da1 (patch) | |
tree | 7cb059b67a55896fdee6a845a33cd1b7abcf6193 /server/sonar-db-dao | |
parent | ae5d2b804c69e4cd19ec13880b913881f620e518 (diff) | |
download | sonarqube-983f593231da12bd64d9df23c18d4f2c7aaa6da1.tar.gz sonarqube-983f593231da12bd64d9df23c18d4f2c7aaa6da1.zip |
SONAR-12246 remove MySQL dialect
Diffstat (limited to 'server/sonar-db-dao')
6 files changed, 0 insertions, 155 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 4ac08ada7a2..f449a0eeabf 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -318,14 +318,6 @@ public class MyBatis implements Startable { return newScrollingSelectStatement(session, sql, fetchSize); } - /** - * Create a PreparedStatement for SELECT requests with scrolling of results row by row (only one row - * in memory at a time) - */ - public PreparedStatement newScrollingSingleRowSelectStatement(DbSession session, String sql) { - int fetchSize = database.getDialect().getScrollSingleRowFetchSize(); - return newScrollingSelectStatement(session, sql, fetchSize); - } private static PreparedStatement newScrollingSelectStatement(DbSession session, String sql, int fetchSize) { try { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index 7914cec53e6..b2dfcc5b225 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -226,10 +226,6 @@ public class ComponentDao implements Dao { return executeLargeInputs(allKeys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, pullRequestId)); } - public List<ComponentDto> selectComponentsHavingSameKeyOrderedById(DbSession session, String key) { - return mapper(session).selectComponentsHavingSameKeyOrderedById(key); - } - /** * List of ancestors, ordered from root to parent. The list is empty * if the component is a tree root. Disabled components are excluded by design diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java index b8045d385c4..0d4a58ded66 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -142,8 +142,6 @@ public interface ComponentMapper { long countGhostProjects(@Param("organizationUuid") String organizationUuid, @Nullable @Param("query") String query); - List<ComponentDto> selectComponentsHavingSameKeyOrderedById(String key); - List<ComponentDto> selectProjectsByNameQuery(@Param("nameQuery") @Nullable String nameQuery, @Param("includeModules") boolean includeModules); void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler); 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 ef48daaf913..69623715619 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 @@ -57,14 +57,6 @@ and pb.branch_type='PULL_REQUEST' </select> - <select id="selectComponentsHavingSameKeyOrderedById" parameterType="String" resultType="Component"> - select - <include refid="componentColumns"/> - from projects p - where p.kee=#{key,jdbcType=VARCHAR} - order BY p.id ASC - </select> - <select id="selectById" parameterType="long" resultType="Component"> SELECT <include refid="componentColumns"/> diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java deleted file mode 100644 index c5b2f924151..00000000000 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.component; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique, - * we need to create a schema where there's no unique index on PROJECTS.KEE - */ - -public class ComponentDaoWithDuplicatedKeysTest { - - private static final String PROJECT_KEY = "PROJECT_KEY"; - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, ComponentDaoWithDuplicatedKeysTest.class, "schema.sql"); - - private DbClient dbClient = db.getDbClient(); - private DbSession dbSession = db.getSession(); - - private ComponentDao underTest = new ComponentDao(); - - @Test - public void select_components_having_same_key() { - OrganizationDto organizationDto = db.organizations().insert(); - insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY)); - insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY)); - insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY)); - insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("ANOTHER_PROJECT_KEY")); - - assertThat(underTest.selectComponentsHavingSameKeyOrderedById(db.getSession(), PROJECT_KEY)).hasSize(3); - } - - @Test - public void return_nothing() { - assertThat(underTest.selectComponentsHavingSameKeyOrderedById(db.getSession(), PROJECT_KEY)).isEmpty(); - } - - private ComponentDto insertProject(ComponentDto project) { - dbClient.componentDao().insert(dbSession, project); - dbSession.commit(); - return project; - } -} diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql b/server/sonar-db-dao/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql deleted file mode 100644 index e6316bd027a..00000000000 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql +++ /dev/null @@ -1,63 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "NEW_PROJECT_PRIVATE" BOOLEAN, - "USER_ID" BIGINT, - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "SUBSCRIPTION" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(4000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); |