-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Runtime Error for count() with order_by clause combined #3815
Comments
Thanks for filling this bug report. Its always a lot of work to find problems in applications, especially if the it requires several steps and a lot unrelated dependencies. Please try to provide a minimized example that does not required additional dependencies outside of diesel and rust-stdlib, otherwise this issue is not really actionable. |
@weiznich I added a minimal project: https://gitlab.com/samtv12345/diesel-issue3815 . The only dependency it includes is dotenv for having a single DATABASE_URL |
Thanks for providing the minimal example. That's helpful. I will try to have a look at that in the next days/weeks. |
Thanks for the help <3. Sorry for misreading the last checkbox. I thought a third party crate would be related to diesel, not in general. |
I can confirm this issue. This also affects queries like |
Setup
Versions
Feature Flags
Problem Description
I am creating a hateoas API. A hateoas API contains besides the data also some metadata containing the amount of elements that are contained with the query (different to the current elements).
To not duplicate code I just clone the normal query and add a .count() to it.
Unfortunately it seems like an order by and a count operator are incompatible and generate incompatible SQL.
What are you trying to accomplish?
I try to create an API for the Etherpad website that allows different sorting by downloads/name etc.
What is the expected output?
The total count query should output the total number of items in this query so that I can lazy load other elements if needed
What is the actual output?
thread 'actix-rt|system:0|arbiter:0' panicked at 'called
Result::unwrap()
on anErr
value: DatabaseError(Unknown, "column "datas.downloads" must appear in the GROUP BY clause or be used in an aggregate function")', src\entities\plugin.rs:162:88stack backtrace:
Are you seeing any additional errors?
No. I had a look at the SQL statements and it is definetely faulty.
Steps to reproduce
git clone https://github.com/SamTV12345/etherpad-plugin-data-extractor.git
If you remove every order_by clause for the count query it works flawlessly. I am unfortunately unsure why this happens. Group by SQL statements shouldn't have anything to do with order by clauses
Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: