-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Setup
Versions
- Rust: 1.83.0
- Diesel: 2.2.6
- Database: Postgresql 16.3
- Operating System Fedora
Feature Flags
- diesel:
postgres
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
- I have already looked over the issue tracker and the discussion forum for similar possible closed issues.
- This issue can be reproduced on Rust's stable channel. (Your issue will be
closed if this is not the case) - This issue can be reproduced without requiring a third party crate