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}; true -> Meta#{count => count(Tab), hasnext => length(Rows) > Limit};
_ -> Meta#{count => -1, hasnext => length(Rows) > Limit} _ -> Meta#{count => -1, hasnext => length(Rows) > Limit}
end, end,
NRows = case SortFun of Data0 = lists:sublist(Rows, Limit),
undefined -> Rows; Data = case SortFun of
_ -> lists:sort(SortFun, Rows) undefined -> Data0;
end, _ -> lists:sort(SortFun, Data0)
#{meta => NMeta, data => lists:sublist(NRows, Limit)}. end,
#{meta => NMeta, data => Data}.
%% @private %% @private
do_query(Node, Qs, {M,F}, Start, Limit) when Node =:= node() -> do_query(Node, Qs, {M,F}, Start, Limit) when Node =:= node() ->