aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorBelen Pruvost <belen.pruvost@sonarsource.com>2021-07-28 17:55:06 +0200
committersonartech <sonartech@sonarsource.com>2021-07-29 20:04:50 +0000
commitc5d6ef5f209111463580bc9bfe7013af30c9ad4b (patch)
treeadbc949d9cdced681de198218493c0e7e540c2ba /server
parent14cd54a8a3eba4a77dd79be0e112f9d10bcd316a (diff)
downloadsonarqube-c5d6ef5f209111463580bc9bfe7013af30c9ad4b.tar.gz
sonarqube-c5d6ef5f209111463580bc9bfe7013af30c9ad4b.zip
SONAR-15148 - Fix Audit paginated query for Oracle
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml36
1 files changed, 35 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml
index 469560c01a5..6b8a9fc5646 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml
@@ -13,10 +13,30 @@
a.created_at as "createdAt"
</sql>
+ <sql id="sqlColumnsInInnerQuery">
+ uuid,
+ user_uuid,
+ user_login,
+ category,
+ operation,
+ new_value,
+ created_at
+ </sql>
+
<select id="selectByPeriodPaginated" parameterType="map" resultType="org.sonar.db.audit.AuditDto">
+ select
+ <include refid="sqlColumns"/>
+ from audits a
+ where
+ a.created_at &gt;= #{start} and a.created_at &lt; #{end}
+ limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
+ </select>
+
+ <select id="selectByPeriodPaginated" parameterType="map" resultType="org.sonar.db.audit.AuditDto" databaseId="mssql">
select <include refid="sqlColumns"/> from (
select
- row_number() over(order by created_at, uuid) as row_number, *
+ row_number() over(order by created_at, uuid) as row_number,
+ <include refid="sqlColumnsInInnerQuery" />
from audits
where created_at &gt;= #{start} and created_at &lt; #{end}
) as a
@@ -25,6 +45,20 @@
order by a.row_number asc
</select>
+ <select id="selectByPeriodPaginated" parameterType="map" resultType="org.sonar.db.audit.AuditDto" databaseId="oracle">
+ select <include refid="sqlColumns"/> from (
+ select rownum as rn, t.* from (
+ select
+ <include refid="sqlColumnsInInnerQuery"/>
+ from audits
+ where created_at &gt;= #{start} and created_at &lt; #{end}
+ ) t
+ ) a
+ where
+ a.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ order by a.rn asc
+ </select>
+
<insert id="insert" parameterType="Map" useGeneratedKeys="false">
INSERT INTO audits
(