Merge pull request #8572 from zhongwencool/query-sort-order

fix: duplicate rule when query by page
This commit is contained in:
zhongwencool 2022-07-26 15:44:43 +08:00 committed by GitHub
commit 489e4fcd74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -98,11 +98,12 @@ node_query(Node, Params, {Tab, QsSchema}, QueryFun, SortFun) ->
true -> Meta#{count => count(Tab), hasnext => length(Rows) > Limit};
_ -> Meta#{count => -1, hasnext => length(Rows) > Limit}
end,
NRows = case SortFun of
undefined -> Rows;
_ -> lists:sort(SortFun, Rows)
Data0 = lists:sublist(Rows, Limit),
Data = case SortFun of
undefined -> Data0;
_ -> lists:sort(SortFun, Data0)
end,
#{meta => NMeta, data => lists:sublist(NRows, Limit)}.
#{meta => NMeta, data => Data}.
%% @private
do_query(Node, Qs, {M,F}, Start, Limit) when Node =:= node() ->