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

AbstractSQLQuery.getResults is not correct on return values #854

bbakerman opened this Issue Jul 17, 2014 · 1 comment


None yet
2 participants

bbakerman commented Jul 17, 2014

There is a minor bug in the getResults such that it respects the input limit and offset but the search result return value is incorrect.

This is because a "queryMetadata.reset()" call is made in the inner list() call and the original limit/offet is lost

I am creating a fork to patch this but in shorts its

    public <RT> SearchResults<RT> listResults(Expression<RT> expr) {
        QueryModifiers originalModifiers = queryMixin.getMetadata().getModifiers();
        try {
            if (configuration.getTemplates().isCountViaAnalytics()) {
                List<RT> results;
                try {
                    getLastCell = true;
                    results = list(expr);
                } finally {
                long total;
                if (!results.isEmpty()) {
                    if (lastCell instanceof Number) {
                        total = ((Number)lastCell).longValue();
                    } else {
                        throw new IllegalStateException("Unsupported lastCell instance " + lastCell);
                } else {
                    total = count();
                return new SearchResults<RT>(results, originalModifiers, total);

            } else {
                long total = count();
                if (total > 0) {
                    return new SearchResults<RT>(list(expr), originalModifiers, total);
                } else {
                    return SearchResults.emptyResults();

        } finally {
            getLastCell = false;

bbakerman added a commit to atlassian/querydsl that referenced this issue Jul 17, 2014

bbakerman added a commit to atlassian/querydsl that referenced this issue Jul 17, 2014

@timowest timowest added the bug label Jul 17, 2014

@timowest timowest added this to the 3.4.2 milestone Jul 17, 2014

@timowest timowest added the fixed label Jul 17, 2014

timowest added a commit that referenced this issue Jul 19, 2014

Merge pull request #855 from atlassian/master
#854 - fixed limit / offset resetting

@timowest timowest modified the milestone: 3.4.2 Jul 19, 2014

@timowest timowest removed the fixed label Jul 19, 2014

@timowest timowest closed this Jul 19, 2014


This comment has been minimized.

Show comment
Hide comment

timowest Jul 29, 2014


Released in 3.4.2


timowest commented Jul 29, 2014

Released in 3.4.2

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