@@ -45,6 +45,7 @@ import org.sonar.db.ce.CeTaskCharacteristicDto; | |||
import org.sonar.db.ce.CeTaskCharacteristicMapper; | |||
import org.sonar.db.ce.CeTaskInputMapper; | |||
import org.sonar.db.ce.CeTaskMessageMapper; | |||
import org.sonar.db.common.Common; | |||
import org.sonar.db.component.AnalysisPropertiesMapper; | |||
import org.sonar.db.component.AnalysisPropertyValuePerProject; | |||
import org.sonar.db.component.ApplicationProjectsMapper; | |||
@@ -344,7 +345,8 @@ public class MyBatis { | |||
UserPermissionMapper.class, | |||
UserTokenMapper.class, | |||
WebhookMapper.class, | |||
WebhookDeliveryMapper.class | |||
WebhookDeliveryMapper.class, | |||
Common.class | |||
}; | |||
confBuilder.loadMappers(mappers); | |||
confExtensions.stream() |
@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 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.common; | |||
public interface Common { | |||
} |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 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. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.db.common; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -32,7 +32,7 @@ | |||
where | |||
a.created_at >= #{start} and a.created_at < #{end} | |||
order by created_at asc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<insert id="insert" parameterType="Map" useGeneratedKeys="false"> |
@@ -85,7 +85,7 @@ | |||
<sql id="sqlSelectByQuery"> | |||
<include refid="sqlSelectByQueryWithoutPagination"/> | |||
order by ca.created_at desc, uuid desc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</sql> | |||
<select id="countByQuery" parameterType="map" resultType="int"> |
@@ -106,13 +106,9 @@ | |||
<include refid="columns"/> | |||
<include refid="sqlSelectByQuery"/> | |||
<include refid="orderByDescDateAndUuid"/> | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="countByQuery" resultType="int"> | |||
select | |||
count(1) | |||
@@ -148,7 +144,7 @@ | |||
select cq.uuid as ceTaskUuid, cq.created_at as createdAt | |||
<include refid="sqlSelectEligibleForPeek"/> | |||
<include refid="orderBySelectEligibleForPeek"/> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="columnsSelectEligibleForPeek"> |
@@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd"> | |||
<mapper namespace="org.sonar.db.common.Common"> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
</mapper> | |||
@@ -215,7 +215,7 @@ | |||
<include refid="componentColumns"/> | |||
<include refid="sqlSelectByQuery"/> | |||
ORDER BY LOWER(p.name), p.name, p.created_at | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countByQuery" resultType="int"> |
@@ -184,13 +184,9 @@ | |||
and s.status = #{status,jdbcType=VARCHAR} | |||
</where> | |||
ORDER BY s.created_at ASC | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="selectSnapshotBefore" resultType="ViewsSnapshot"> | |||
SELECT | |||
<include refid="viewsSnapshotColumns" /> |
@@ -547,7 +547,7 @@ | |||
</foreach> | |||
</if> | |||
order by i.kee | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="selectIssueKeysByComponentUuidAndChangedSinceDate" parameterType="map" resultType="string"> | |||
@@ -578,7 +578,7 @@ | |||
</foreach> | |||
</if> | |||
order by i.kee | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="selectByComponentUuidPaginated" parameterType="map" resultMap="issueResultMap"> | |||
@@ -595,7 +595,7 @@ | |||
left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid | |||
where i.project_uuid=#{componentUuid,jdbcType=VARCHAR} | |||
order by i.issue_creation_date ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="selectByBranchColumns"> | |||
@@ -727,6 +727,6 @@ | |||
<!-- order by clause is required if using offset rows fetch next on MSSQL Database --> | |||
order by (select null) | |||
</if> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
</mapper> |
@@ -45,7 +45,7 @@ | |||
m.enabled=${_true} | |||
</where> | |||
ORDER BY UPPER(m.short_name), m.short_name | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countEnabled" resultType="Integer"> |
@@ -75,13 +75,9 @@ | |||
<include refid="groupsByQuery"/> | |||
group by sub.name, lower(sub.name), sub.groupUuid | |||
order by case when (count(sub.permission) > 0) then 1 else 2 end asc, lower(sub.name), sub.name, sub.groupUuid | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="countGroupsByQuery" parameterType="map" resultType="int"> | |||
select count(1) | |||
from ( |
@@ -94,7 +94,7 @@ | |||
<include refid="userLoginsByQueryAndTemplate"/> | |||
group by u.login, u.name | |||
order by case when (count(ptu.permission_reference) > 0) then 1 else 2 end asc, u.name | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countUserLoginsByQueryAndTemplate" parameterType="map" resultType="int"> | |||
@@ -128,7 +128,7 @@ | |||
<include refid="groupNamesByQueryAndTemplate"/> | |||
group by groups.name, lower(groups.name), groups.group_uuid | |||
order by case when (count(groups.permission) > 0) then 1 else 2 end asc, lower(groups.name), groups.name, groups.group_uuid | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countGroupNamesByQueryAndTemplate" parameterType="map" resultType="int"> | |||
@@ -138,10 +138,6 @@ | |||
<include refid="groupNamesByQueryAndTemplate"/>) g | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<sql id="groupNamesByQueryAndTemplate"> | |||
FROM | |||
(SELECT |
@@ -50,7 +50,7 @@ | |||
#{uuid,jdbcType=VARCHAR} | |||
</foreach> | |||
order by p.name, uuid desc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="selectProjectsByKeys" resultType="Project"> |
@@ -33,7 +33,7 @@ | |||
SELECT g.uuid as groupUuid, g.name as name, qggp.uuid as uuid | |||
<include refid="sqlSelectByQuery"/> | |||
ORDER BY g.name ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countByQuery" resultType="int"> |
@@ -41,7 +41,7 @@ | |||
SELECT u.uuid as userUuid, u.name as name, qup.uuid as uuid | |||
<include refid="sqlSelectByQuery"/> | |||
ORDER BY u.name ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="sqlSelectByQuery"> |
@@ -29,7 +29,7 @@ | |||
SELECT g.uuid as groupUuid, g.name as name, qeg.uuid as uuid | |||
<include refid="sqlSelectByQuery"/> | |||
ORDER BY g.name ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="sqlSelectByQuery"> |
@@ -27,7 +27,7 @@ | |||
SELECT u.uuid as userUuid, u.name as name, qeu.uuid as uuid | |||
<include refid="sqlSelectByQuery"/> | |||
ORDER BY u.name ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="sqlSelectByQuery"> |
@@ -39,13 +39,9 @@ | |||
where g.name = #{query.displayName,jdbcType=VARCHAR} | |||
</if> | |||
order by s.scim_uuid asc | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="countScimGroups" resultType="int"> | |||
select count(1) | |||
from scim_groups s |
@@ -56,13 +56,9 @@ | |||
<include refid="scimUsersColumns"/> | |||
<include refid="sqlSelectByQuery"/> | |||
order by s.scim_uuid asc | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="countScimUsers" parameterType="map" resultType="int"> | |||
select count(1) | |||
<include refid="sqlSelectByQuery"/> |
@@ -95,13 +95,9 @@ | |||
from groups g | |||
<include refid="searchByQueryWhereClause"/> | |||
order by upper(g.name) | |||
<include refid="pagination"/> | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<sql id="pagination"> | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
</sql> | |||
<select id="countByQuery" parameterType="map" resultType="int"> | |||
select count(1) | |||
from groups g |
@@ -25,7 +25,7 @@ | |||
SELECT g.uuid as uuid, g.name as name, g.description as description, gu.user_uuid as userUuid | |||
<include refid="commonClauses"/> | |||
ORDER BY g.name | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countGroups" parameterType="map" resultType="int"> | |||
@@ -99,7 +99,7 @@ | |||
SELECT u.uuid as uuid, u.login as login, u.name as name, gu.group_uuid as groupUuid | |||
<include refid="userCommonClauses"/> | |||
ORDER BY u.name ASC | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countMembers" parameterType="map" resultType="int"> |
@@ -104,7 +104,7 @@ | |||
<include refid="selectFromUsersAndJoinScmAccounts"/> | |||
<include refid="searchByQueryWhereClause"/> | |||
ORDER BY u.login | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countByQuery" parameterType="map" resultType="int"> |
@@ -38,7 +38,7 @@ | |||
from webhook_deliveries | |||
where webhook_uuid = #{webhookUuid,jdbcType=VARCHAR} | |||
order by created_at desc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countByProjectUuid" parameterType="String" resultType="int"> | |||
@@ -53,7 +53,7 @@ | |||
from webhook_deliveries | |||
where project_uuid = #{projectUuid,jdbcType=VARCHAR} | |||
order by created_at desc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="selectOrderedByCeTaskUuid" resultType="org.sonar.db.webhook.WebhookDeliveryLiteDto"> | |||
@@ -61,7 +61,7 @@ | |||
from webhook_deliveries | |||
where ce_task_uuid = #{ceTaskUuid,jdbcType=VARCHAR} | |||
order by created_at desc | |||
offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only | |||
<include refid="org.sonar.db.common.Common.pagination"/> | |||
</select> | |||
<select id="countByCeTaskUuid" parameterType="String" resultType="int"> |