Setup
Versions
- Rust: 1.83.0
- Diesel: 2.2.6
- Database: Postgresql 16.3
- Operating System Fedora
Feature Flags
Problem Description
use diesel::prelude::*;
diesel::table! {
users {
id -> Integer,
name -> Text,
}
}
fn main() {
let mut conn = PgConnection::establish("postgres://localhost/diesel_tests").unwrap();
users::table
.select(diesel::dsl::max(users::id))
.order_by(users::name)
.load::<Option<i32>>(&mut conn)
.unwrap();
}
What are you trying to accomplish?
Build a query that uses ORDER BY and aggregate functions
What is the expected output?
The compilation fails as the query is invalid
What is the actual output?
Compilation succeeds, but the application fails to run the query with the following message:
thread 'main' panicked at src/main.rs:16:10:
called `Result::unwrap()` on an `Err` value: DatabaseError(Unknown, "column \"users.name\" must appear in the GROUP BY clause or be used in an aggregate function")
Steps to reproduce
Run the code above
Checklist
Setup
Versions
Feature Flags
postgresProblem Description
What are you trying to accomplish?
Build a query that uses
ORDER BYand aggregate functionsWhat is the expected output?
The compilation fails as the query is invalid
What is the actual output?
Compilation succeeds, but the application fails to run the query with the following message:
Steps to reproduce
Run the code above
Checklist
closed if this is not the case)