Skip to content

Commit f3cdbaf

Browse files
authored
Merge pull request #8 from sgoll/backport-4076-4116-4398
2 parents 5291e99 + 8c56ba2 commit f3cdbaf

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi
1818
* Adjust a custom compile error message
1919
* Fix a bug that restricted the number of allowed columns in `COPY FROM` statements to 12
2020
* Expose some SqliteValue helper functions
21+
* Use consistent whitespace in `ASC`/`DESC`, `DISTINCT ON`, and `DELETE FROM` clauses
2122

2223
## [2.2.7] 2025-01-31
2324

diesel/src/expression/operators.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,12 @@ postfix_operator!(IsNull, " IS NULL");
540540
postfix_operator!(IsNotNull, " IS NOT NULL");
541541
postfix_operator!(
542542
Asc,
543-
" ASC ",
543+
" ASC",
544544
crate::expression::expression_types::NotSelectable
545545
);
546546
postfix_operator!(
547547
Desc,
548-
" DESC ",
548+
" DESC",
549549
crate::expression::expression_types::NotSelectable
550550
);
551551

diesel/src/pg/query_builder/distinct_on.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ where
271271
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
272272
out.push_sql("DISTINCT ON (");
273273
self.0.walk_ast(out.reborrow())?;
274-
out.push_sql(")");
274+
out.push_sql(") ");
275275
Ok(())
276276
}
277277
}

diesel/src/query_builder/delete_statement/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ where
259259
Ret: QueryFragment<DB>,
260260
{
261261
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()> {
262-
out.push_sql("DELETE ");
262+
out.push_sql("DELETE");
263263
self.from_clause.walk_ast(out.reborrow())?;
264264
self.where_clause.walk_ast(out.reborrow())?;
265265
self.returning.walk_ast(out.reborrow())?;

examples/mysql/all_about_inserts/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn examine_sql_from_insert_get_results_batch() {
320320
`users`.`hair_color`, `users`.`created_at`, \
321321
`users`.`updated_at` \
322322
FROM `users` \
323-
ORDER BY `users`.`id` DESC \
323+
ORDER BY `users`.`id` DESC \
324324
-- binds: []";
325325
assert_eq!(load_sql, debug_query::<Mysql, _>(&load_query).to_string());
326326
}
@@ -372,7 +372,7 @@ fn examine_sql_from_insert_get_result() {
372372
`users`.`hair_color`, `users`.`created_at`, \
373373
`users`.`updated_at` \
374374
FROM `users` \
375-
ORDER BY `users`.`id` DESC \
375+
ORDER BY `users`.`id` DESC \
376376
-- binds: []";
377377
assert_eq!(load_sql, debug_query::<Mysql, _>(&load_query).to_string());
378378
}
@@ -399,7 +399,7 @@ fn examine_sql_from_explicit_returning() {
399399
debug_query::<Mysql, _>(&insert_query).to_string()
400400
);
401401
let load_query = users.select(id).order(id.desc());
402-
let load_sql = "SELECT `users`.`id` FROM `users` ORDER BY `users`.`id` DESC -- binds: []";
402+
let load_sql = "SELECT `users`.`id` FROM `users` ORDER BY `users`.`id` DESC -- binds: []";
403403
assert_eq!(load_sql, debug_query::<Mysql, _>(&load_query).to_string());
404404
}
405405

0 commit comments

Comments
 (0)