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

count(*) with ORDER BY returns empty result if no rows exist #9110

Closed
mmacfadden opened this issue Jan 18, 2020 · 2 comments
Closed

count(*) with ORDER BY returns empty result if no rows exist #9110

mmacfadden opened this issue Jan 18, 2020 · 2 comments
Assignees

Comments

@mmacfadden
Copy link
Contributor

OrientDB Version: 3.0.26

Java Version: openJDK 11

OS: MacOS

Issue:

When performing a count with an ORDER BY. If no rows match, instead of getting a result with a count field set to 0, we get an empty result set. This is similar to #8280 and #8621 which I had previously reported.

Expected behavior

A count result of 0 should be returned.

Actual behavior

An empty result set is returned.

Steps to reproduce

Create the schema:

CREATE CLASS Test;
CREATE Property Test.id String;

Test 1 (Works)

SELECT count(*) as count FROM Test;
    "result": [
        {
            "@type": "d",
            "@version": 0,
            "count": 0,
            "@fieldTypes": "count=l"
        }
    ]

Test 2 (Doesn't Work)

SELECT count(*) as count FROM Test ORDER BY id ASC;
    "result": [
        
    ]
@luigidellaquila
Copy link
Member

Hi @mmacfadden

this query does not make much sense semantically, but I think it's worth fixing anyway.
I'm pushing a fix now, it will be released with v 3.0.28

Thanks

@mmacfadden
Copy link
Contributor Author

@luigidellaquila Thanks! You are correct, it is a little non-sensical. This came up because we were working with pagination and we have a utility that essentially takes your original query (that might have SKIP and LIMIT in it) and builds a second query that does the count to get the total result. The order by was coming from the original query!

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

No branches or pull requests

2 participants