Skip to content

Commit

Permalink
Preserve previous trailing-comma behavior
Browse files Browse the repository at this point in the history
Because most likely there are quickly enough tables in there that it is formatted with one table per line, for which the best display is then to have the trailing comma, for the same rationale as rustfmt describes.

(Also that should fix tests)
  • Loading branch information
Ten0 committed Mar 3, 2025
1 parent df21755 commit db44507
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions diesel_cli/src/print_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use serde::{Deserialize, Serialize};
use std::collections::{BTreeSet, HashSet};
use std::fmt::{self, Display, Formatter, Write};
use std::io::Write as IoWrite;
use std::process;
use std::str;
use std::{process, str};

const SCHEMA_HEADER: &str = "// @generated automatically by Diesel CLI.\n";

Expand Down Expand Up @@ -598,11 +597,8 @@ impl Display for TableDefinitions<'_> {
{
let mut out = PadAdapter::new(f);
writeln!(out)?;
for (table_index, table) in table_group.into_iter().enumerate() {
if table_index != 0 {
write!(out, ", ")?;
}
write!(out, "{}", table.rust_name)?;
for table in table_group {
write!(out, "{},", table.rust_name)?;
}
}
writeln!(f, ");")?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ diesel::joinable!(comments -> posts (post_id));
diesel::joinable!(posts -> users (user_id));
diesel::joinable!(transactions -> sessions (session_id));

diesel::allow_tables_to_appear_in_same_query!(comments, posts, users);
diesel::allow_tables_to_appear_in_same_query!(sessions, transactions);
diesel::allow_tables_to_appear_in_same_query!(comments, posts, users,);
diesel::allow_tables_to_appear_in_same_query!(sessions, transactions,);

0 comments on commit db44507

Please sign in to comment.