Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit offset return wrong result #1903

Closed
keitho00 opened this issue Feb 21, 2019 · 1 comment
Closed

limit offset return wrong result #1903

keitho00 opened this issue Feb 21, 2019 · 1 comment

Comments

@keitho00
Copy link

keitho00 commented Feb 21, 2019

Which version of ShardingSphere did you use?

3.1.0

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

java code

        List<ProfitJournal> profitJournalPage1 = profitJournalMapper.selectPage(ProfitJournal.Query.builder()
                        .userId(20162268)
                        .build(), 1550627000L, 1550628875L
                , 5, 5);

mybaits xml

<select id="selectPage" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from profit_journal
    <where>
        <if test="query.userId != null">
            and user_id = #{query.userId}
        </if>
        <if test="query.guildId != null">
            and guild_id = #{query.guildId}
        </if>
    
        <if test="query.profitType != null">
            and profit_type = #{query.profitType}
        </if>
        <if test="query.memberType != null">
            and member_type = #{query.memberType}
        </if>
        <if test="query.month != null">
            and `month` = #{query.month}
        </if>
        <if test="beginTime != null and endTime != null">
            and dateline between #{beginTime} and #{endTime}
        </if>
        order by id
        LIMIT #{offset},#{limit}
    </where>
</select>

Expect Sql

SELECT
	* 
FROM
	profit_journal_20190220 
WHERE
	user_id = ?and dateline between ? and ? LIMIT ?, ?  ::: [[20162268, 1550627000, 1550628875, 5, 5]]

Actual Sql

SELECT
	* 
FROM
	profit_journal_20190220 
WHERE
	user_id = ?and dateline between ? and ? LIMIT ?, ?  ::: [[20162268, 1550627000, 1550628875, 0, 10]]

two sql limit param is different

Result

image

I want 5 result but get 10 result ,I think there is something wrong .

@tuohai666
Copy link
Member

Known issue, please refer to #1722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants