Repository: diesel-rs/diesel (language: rust)

Issue:
Missing type alias OrderBy for dsl::auto_type
## Setup

### Versions

- **Rust:** rustc --version = rustc 1.70.0 (90c541806 2023-05-31)
- **Diesel:** master
- **Database:** _
- **Operating System** Archlinux

### Feature Flags

- **diesel:** "postgres", "r2d2", "serde_json", "chrono",

## Problem Description
QueryDsl provides an alias for `order` named [`order_by`](https://docs.rs/diesel/latest/diesel/prelude/trait.QueryDsl.html#method.order_by). Therefore type generated using `#[dsl::auto_type]` is `diesel::dsl::OrderBy` which does not exists! I therefore think we should add a type alias `OrderBy` for `Order`.

I see two other alternatives:
1. Deprecate `order_by` on QueryDsl
2. Add documentation on `order_by` to indicate that it doesn't work with `dsl::auto_type` and that one should use `order` in that case.

I can provide a PR once solution has been chosen.

### What are you trying to accomplish?
Use  `#[dsl::auto_type]`

### What is the expected output?
I'd like a simplier solution to use dsl::auto_type

### What is the actual output?


### Are you seeing any additional errors?


### Steps to reproduce

## Checklist

- [x] I have already looked over the [issue tracker](https://github.com/diesel-rs/diesel/issues) and the [discussion forum](https://github.com/diesel-rs/diesel/discussions) for similar possible closed issues.
- [x] This issue can be reproduced on Rust's stable channel. (Your issue will be
  closed if this is not the case)
- [x] This issue can be reproduced without requiring a third party crate


Discussion / hints:
Thanks for reporting. I'm happy to accept a PR that just adds a `type Order = OrderBy` to `diesel::dsl`.

Fix patch:
diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs
index f6ec5ba35713..dff8dfbba3cf 100644
--- a/diesel/src/lib.rs
+++ b/diesel/src/lib.rs
@@ -398,6 +398,11 @@ pub mod helper_types {
     /// Represents the return type of [`.order(ordering)`](crate::prelude::QueryDsl::order)
     pub type Order<Source, Ordering> = <Source as OrderDsl<Ordering>>::Output;
 
+    /// Represents the return type of [`.order_by(ordering)`](crate::prelude::QueryDsl::order_by)
+    ///
+    /// Type alias of [Order]
+    pub type OrderBy<Source, Ordering> = Order<Source, Ordering>;
+
     /// Represents the return type of [`.then_order_by(ordering)`](crate::prelude::QueryDsl::then_order_by)
     pub type ThenOrderBy<Source, Ordering> = <Source as ThenOrderDsl<Ordering>>::Output;
 
diff --git a/diesel/src/query_dsl/mod.rs b/diesel/src/query_dsl/mod.rs
index a8c7eab5b0a8..d8fc1e2772c5 100644
--- a/diesel/src/query_dsl/mod.rs
+++ b/diesel/src/query_dsl/mod.rs
@@ -789,7 +789,7 @@ pub trait QueryDsl: Sized {
     }
 
     /// Alias for `order`
-    fn order_by<Expr>(self, expr: Expr) -> Order<Self, Expr>
+    fn order_by<Expr>(self, expr: Expr) -> OrderBy<Self, Expr>
     where
         Expr: Expression,
         Self: methods::OrderDsl<Expr>,


Test patch: