return new OffsetBasedPagination(startRowNumber - 1, pageSize);
}
- @Override
- public int getStartRowNumber() {
- return offset + 1;
- }
-
@Override
public int getOffset() {
return offset;
return (page - 1) * pageSize;
}
- @Override
- public int getStartRowNumber() {
- return getOffset() + 1;
- }
-
public int getEndRowNumber() {
return page * pageSize;
}
public interface Pagineable {
- int getStartRowNumber();
-
int getOffset();
int getPageSize();
from audits a
where
a.created_at >= #{start} and a.created_at < #{end}
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="selectByPeriodPaginated" parameterType="map" resultType="org.sonar.db.audit.AuditDto" databaseId="mssql">
where created_at >= #{start} and created_at < #{end}
) as a
where
- a.row_number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ a.row_number between (#{pagination.offset,jdbcType=INTEGER}+1) and #{pagination.endRowNumber,jdbcType=INTEGER}
order by a.row_number asc
</select>
) t
) a
where
- a.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ a.rn between (#{pagination.offset,jdbcType=INTEGER}+1) and #{pagination.endRowNumber,jdbcType=INTEGER}
order by a.rn asc
</select>
<sql id="sqlSelectByQuery">
<include refid="sqlSelectByQueryWithoutPagination"/>
order by ca.created_at desc, uuid desc
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<select id="countByQuery" parameterType="map" resultType="int">
</select>
<sql id="pagination">
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<select id="countByQuery" resultType="int">
select cq.uuid as ceTaskUuid, cq.created_at as createdAt
<include refid="sqlSelectEligibleForPeek"/>
<include refid="orderBySelectEligibleForPeek"/>
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectEligibleForPeek" parameterType="map" resultType="org.sonar.db.ce.CeTaskDtoLight" databaseId="mssql">
- select query.uuid as ceTaskUuid, query.created_at as createdAt from (
- select
- row_number() over(<include refid="orderBySelectEligibleForPeek"/>) as number,
- <include refid="columnsSelectEligibleForPeek"/>
- <include refid="sqlSelectEligibleForPeek"/>
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by number asc
- </select>
-
- <select id="selectEligibleForPeek" parameterType="map" resultType="org.sonar.db.ce.CeTaskDtoLight" databaseId="oracle">
- select taskuuid as ceTaskUuid, createdat as createdAt from (
- select rownum as rn, t."uuid" as taskuuid, t."created_at" as createdat from (
- select
- <include refid="columnsSelectEligibleForPeek"/>
- <include refid="sqlSelectEligibleForPeek"/>
- <include refid="orderBySelectEligibleForPeek"/>
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<sql id="columnsSelectEligibleForPeek">
<include refid="componentColumns"/>
<include refid="sqlSelectByQuery"/>
ORDER BY LOWER(p.name), p.name, p.created_at
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countByQuery" resultType="int">
</select>
<sql id="pagination">
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<select id="selectSnapshotBefore" resultType="ViewsSnapshot">
</foreach>
</if>
order by i.kee
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectIssueKeysByComponentUuidWithFilters" parameterType="map" resultType="string" databaseId="mssql">
- select
- i.kee
- from
- (select
- row_number() over(order by i.kee ASC) as row_number,
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by row_number asc
- offset #{pagination.offset} rows
- fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only) i
- </select>
-
- <select id="selectIssueKeysByComponentUuidWithFilters" parameterType="map" resultType="string" databaseId="oracle">
- select
- i.kee
- from (
- select rownum as rn, t.* from (
- select
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by i.kee ASC
- ) t ) i
- where
- i.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by i.rn asc
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="selectIssueKeysByComponentUuidAndChangedSinceDate" parameterType="map" resultType="string">
</foreach>
</if>
order by i.kee
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectIssueKeysByComponentUuidAndChangedSinceDate" parameterType="map" resultType="string" databaseId="mssql">
- select
- i.kee
- from
- (select
- row_number() over(order by i.kee ASC) as row_number,
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.issue_update_date >= #{changedSince,jdbcType=BIGINT}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by row_number asc
- offset #{pagination.offset} rows
- fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only) i
- </select>
-
- <select id="selectIssueKeysByComponentUuidAndChangedSinceDate" parameterType="map" resultType="string" databaseId="oracle">
- select
- i.kee
- from
- (select rownum as rn, t.* from (
- select
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.issue_update_date >= #{changedSince,jdbcType=BIGINT}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by i.kee ASC
- ) t
- ) i
- where
- i.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by i.rn asc
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="selectByComponentUuidPaginated" parameterType="map" resultMap="issueResultMap">
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
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByComponentUuidPaginated" parameterType="map" resultMap="issueResultMap" databaseId="mssql">
- select
- <include refid="issueColumns"/>,
- u.login as assigneeLogin
- from
- (select
- row_number() over(order by i.issue_creation_date ASC) as row_number,
- <include refid="issueColumnsInInnerQuery"/>
- from issues i
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- order by row_number asc
- offset #{pagination.offset} rows
- fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only) i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join users u on i.assignee = u.uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- </select>
-
- <select id="selectByComponentUuidPaginated" parameterType="map" resultMap="issueResultMap" databaseId="oracle">
- select
- <include refid="issueColumns"/>,
- u.login as assigneeLogin
- from
- (select <include refid="issueColumnsInInnerQuery"/> from (
- select rownum as rn, t.* from (
- select
- <include refid="issueColumnsInInnerQuery"/>
- from issues i
- where i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- order by i.issue_creation_date ASC
- ) t
- ) i
- where
- i.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by i.rn asc) i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join users u on i.assignee = u.uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<sql id="selectByBranchColumns">
<!-- order by clause is required if using offset rows fetch next on MSSQL Database -->
order by (select null)
</if>
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
</mapper>
m.enabled=${_true}
</where>
ORDER BY UPPER(m.short_name), m.short_name
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countEnabled" resultType="Integer">
</select>
<sql id="pagination">
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<select id="countGroupsByQuery" parameterType="map" resultType="int">
</select>
<sql id="pagination">
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<sql id="groupNamesByQueryAndTemplate">
#{uuid,jdbcType=VARCHAR}
</foreach>
order by p.name, uuid desc
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="selectProjectsByKeys" resultType="Project">
SELECT g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
<include refid="sqlSelectByQuery"/>
ORDER BY g.name ASC
- LIMIT #{pagination.pageSize,jdbcType=INTEGER}
- OFFSET #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="mssql">
- select * from (
- select row_number() over(order by g.name asc) as number,
- g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
- <include refid="sqlSelectByQuery" />
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by query.name asc
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="oracle">
- select * from (
- select rownum as rn, t.* from (
- select g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- order by g.name ASC
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countByQuery" resultType="int">
SELECT u.uuid as userUuid, u.name as name, qup.uuid as uuid
<include refid="sqlSelectByQuery"/>
ORDER BY u.name ASC
- LIMIT #{pagination.pageSize,jdbcType=INTEGER}
- OFFSET #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
- databaseId="mssql">
- select * from (
- select row_number() over(order by u.name asc) as number,
- u.uuid as userUuid, u.name as name, qup.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by query.name asc
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
- databaseId="oracle">
- select * from (
- select rownum as rn, t.* from (
- select u.uuid as userUuid, u.name as name, qup.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- order by u.name ASC
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<sql id="sqlSelectByQuery">
SELECT g.uuid as groupUuid, g.name as name, qeg.uuid as uuid
<include refid="sqlSelectByQuery"/>
ORDER BY g.name ASC
- LIMIT #{pagination.pageSize,jdbcType=INTEGER}
- OFFSET #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="mssql">
- select * from (
- select row_number() over(order by g.name asc) as number,
- g.uuid as groupUuid, g.name as name, qeg.uuid as uuid
- <include refid="sqlSelectByQuery" />
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by query.name asc
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="oracle">
- select * from (
- select rownum as rn, t.* from (
- select g.uuid as groupUuid, g.name as name, qeg.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- order by g.name ASC
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<sql id="sqlSelectByQuery">
SELECT u.uuid as userUuid, u.name as name, qeu.uuid as uuid
<include refid="sqlSelectByQuery"/>
ORDER BY u.name ASC
- LIMIT #{pagination.pageSize,jdbcType=INTEGER}
- OFFSET #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
- databaseId="mssql">
- select * from (
- select row_number() over(order by u.name asc) as number,
- u.uuid as userUuid, u.name as name, qeu.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by query.name asc
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
- databaseId="oracle">
- select * from (
- select rownum as rn, t.* from (
- select u.uuid as userUuid, u.name as name, qeu.uuid as uuid
- <include refid="sqlSelectByQuery"/>
- order by u.name ASC
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<sql id="sqlSelectByQuery">
</select>
<sql id="pagination">
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</sql>
<select id="countByQuery" parameterType="map" resultType="int">
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.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countGroups" parameterType="map" resultType="int">
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.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countMembers" parameterType="map" resultType="int">
<include refid="selectFromUsersAndJoinScmAccounts"/>
<include refid="searchByQueryWhereClause"/>
ORDER BY u.login
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectUsers" parameterType="map" resultMap="userResultMap" databaseId="mssql">
- SELECT
- <include refid="usersAndScmAccountsColumns"/>
- FROM
- (SELECT
- <include refid="searchByQueryInnerQueryColumns"/>
- FROM users u
- <include refid="searchByQueryWhereClause"/>
- ORDER BY u.login
- offset #{pagination.offset} rows
- fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
- ) u
- <include refid="leftOuterJoinScmAccounts"/>
- </select>
-
- <select id="selectUsers" parameterType="map" resultMap="userResultMap" databaseId="oracle">
- SELECT
- <include refid="usersAndScmAccountsColumns"/>
- FROM
- (SELECT rownum as rn, t.* from (
- SELECT
- <include refid="searchByQueryInnerQueryColumns"/>
- FROM users u
- <include refid="searchByQueryWhereClause"/>
- ORDER BY u.login ASC
- ) t
- ) u
- <include refid="leftOuterJoinScmAccounts"/>
- WHERE
- u.rn BETWEEN #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- ORDER BY u.rn ASC
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countByQuery" parameterType="map" resultType="int">
from webhook_deliveries
where webhook_uuid = #{webhookUuid,jdbcType=VARCHAR}
order by created_at desc
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countByProjectUuid" parameterType="String" resultType="int">
from webhook_deliveries
where project_uuid = #{projectUuid,jdbcType=VARCHAR}
order by created_at desc
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="selectOrderedByCeTaskUuid" resultType="org.sonar.db.webhook.WebhookDeliveryLiteDto">
from webhook_deliveries
where ce_task_uuid = #{ceTaskUuid,jdbcType=VARCHAR}
order by created_at desc
- offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
</select>
<select id="countByCeTaskUuid" parameterType="String" resultType="int">
}
@Test
- public void forOffset_whenZeroOffset_shouldStartRowNumberAtOne() {
+ public void forOffset_whenZeroOffset_shouldStartOffsetAtZero() {
assertThat(OffsetBasedPagination.forOffset(0, 100))
- .extracting(p -> p.getStartRowNumber(), p -> p.getOffset(), p -> p.getPageSize())
- .containsExactly(1, 0, 100);
+ .extracting(p -> p.getOffset(), p -> p.getPageSize())
+ .containsExactly(0, 100);
}
@Test
.hasMessage("page size must be >= 1");
}
- @Test
- public void forStartRowNumber_whenZeroOffset_shouldStartRowNumberAtOne() {
- assertThat(OffsetBasedPagination.forStartRowNumber(1, 100))
- .extracting(p -> p.getStartRowNumber(), p -> p.getOffset(), p -> p.getPageSize())
- .containsExactly(1, 0, 100);
- }
-
@Test
public void equals_whenSameParameters_shouldBeTrue() {
Assertions.assertThat(OffsetBasedPagination.forStartRowNumber(15, 20))
assertThat(forPage(5).andSize(1).getOffset()).isEqualTo(4);
}
- @Test
- public void startRowNumber_is_computed_from_page_and_size() {
- assertThat(forPage(2).andSize(3).getStartRowNumber()).isEqualTo(4);
- assertThat(forPage(5).andSize(3).getStartRowNumber()).isEqualTo(13);
- assertThat(forPage(5).andSize(1).getStartRowNumber()).isEqualTo(5);
- }
-
@Test
public void endRowNumber_is_computed_from_page_and_size() {
assertThat(forPage(2).andSize(3).getEndRowNumber()).isEqualTo(6);