fix: always check if first query has more rows

This commit is contained in:
Thales Macedo Garitezi 2024-05-13 09:10:18 -03:00
parent e25fe62cbc
commit 0dee2d67b1
1 changed files with 2 additions and 2 deletions

View File

@ -443,13 +443,13 @@ maybe_fetch_from_second_query(Params) ->
} = Params, } = Params,
NumRows1 = length(Data1), NumRows1 = length(Data1),
{Data, HN} = {Data, HN} =
case NumRows1 >= Limit of case (NumRows1 >= Limit) orelse HN1 of
true -> true ->
{Data1, HN1 orelse C2 > 0}; {Data1, HN1 orelse C2 > 0};
false -> false ->
#{data := Data2, meta := #{hasnext := HN2}} = #{data := Data2, meta := #{hasnext := HN2}} =
Q2(QString0#{<<"limit">> := Limit - NumRows1}), Q2(QString0#{<<"limit">> := Limit - NumRows1}),
{Data1 ++ Data2, HN1 or HN2} {Data1 ++ Data2, HN2}
end, end,
#{ #{
data => Data, data => Data,