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

Issue:
style: schema.rs doesn't comply with rustfmt
<!--
If you want to report a bug, we added some points below which help us track down the problem faster.
-->

## Setup

### Versions

- **Rust:** 1.80.1
- **Diesel:** 2.2.4 (cli)
- **Database:** Postgresql
- **Operating System** Linux

### Feature Flags

- **diesel:** N/A

## Problem Description

The `schema.rs` file created by diesel-cli when running a migration doesn't always comply with rustfmt

### What are you trying to accomplish?

I'm trying to use the diesel-cli to generate the migrations and the `schema.rs` file  

### What is the expected output?

Running `cargo fmt -- --check` should produce no errors.

### What is the actual output?

Depending on the number of tables, the `schema.rs` file is not formatted properly and thus resulting in an error when running cargo fmt

### Are you seeing any additional errors?

No

### Steps to reproduce

0. Setup a basic diesel and cargo project 

1. Generate a migration

```bash
diesel migration generate migration1
```

Put the following into your `migrations/XXX_migration1/up.sql

```sql
CREATE TABLE t0 (id SERIAL PRIMARY KEY);
CREATE TABLE t1 (id SERIAL PRIMARY KEY, t0_id INTEGER NOT NULL REFERENCES t0);
```

2. Run the diesel migration

```bash
diesel migration run
```
 
3. Add this on top of your `main.rs`

```rs
mod schema;
```

4. Run cargo fmt

```bash
cargo fmt -- --check 
```

Output:
```
Diff in XXX/src/schema.rs at line 15:
 
 diesel::joinable!(t1 -> t0 (t0_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    t0,
-    t1,
-);
+diesel::allow_tables_to_appear_in_same_query!(t0, t1,);
``` 

You can checkout a test repository [here](https://github.com/AndreCostaaa/diesel-fmt-test)


<!--
Please include as much of your codebase as needed to reproduce the error.  If the relevant files are large, please consider linking to a public repository or a [Gist](https://gist.github.com/). This includes normally the following parts:

* The exact code where your hit the problem
* Relevant parts your schema, so any `table!` macro calls required for
* Any other type definitions involved in the code, which produces your problem
-->

## 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.
<!--
If you are unsure if your issue is a duplicate of an existing issue please link the issue in question here
--> 
- [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

<!--
Thank you for your submission!  You're helping make Diesel more robust 🎉

We'll try to respond as quickly as possible.
-->



Discussion / hints:
Thanks for opening this issue. Diesel cli emits a `@generated` which should instruct rustfmt to ignore this file. If that doesn't work this seems to be more a rustfmt issue and should be reported there. 

That written: I'm open to accept a PR that emits the correct formatting in this case. For larger schemas that already works but for only a few tables that doesn't seem to be perfect. 
> I'm open to accept a PR that emits the correct formatting in this case

Would spawning a `rustfmt` process from the `diesel-cli` after writting the `schema.rs` file be acceptable for you?



If that works reliably with the patching mechanism it would be acceptable to just use rustfmt for this as long as its failure tolerant if rustfmt is not installed. 
Exactly what I had in mind. Will send a PR soon

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9e01a9f913e5..45cbc9f0b25e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -174,6 +174,7 @@ jobs:
         uses: dtolnay/rust-toolchain@master
         with:
           toolchain: ${{ matrix.rust }}
+          components: rustfmt
 
       - name: Rust version check
         shell: bash
diff --git a/diesel_cli/src/errors.rs b/diesel_cli/src/errors.rs
index 8f538503d5b5..21e6e18fd7d6 100644
--- a/diesel_cli/src/errors.rs
+++ b/diesel_cli/src/errors.rs
@@ -62,6 +62,8 @@ pub enum Error {
     ClapMatchesError(#[from] clap::parser::MatchesError),
     #[error("No `[print_schema.{0}]` entries in your diesel.toml")]
     NoSchemaKeyFound(String),
+    #[error("Failed To Run rustfmt")]
+    RustFmtFail(String),
 }
 
 fn print_optional_path(path: &Option<PathBuf>) -> String {
diff --git a/diesel_cli/src/main.rs b/diesel_cli/src/main.rs
index 7195fd426a6c..08962f20b1f4 100644
--- a/diesel_cli/src/main.rs
+++ b/diesel_cli/src/main.rs
@@ -276,9 +276,8 @@ fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), crate
                     .map_err(|e| crate::errors::Error::IoError(e, Some(parent.to_owned())))?;
             }
 
+            let schema = print_schema::output_schema(&mut connection, config)?;
             if matches.get_flag("LOCKED_SCHEMA") {
-                let schema = print_schema::output_schema(&mut connection, config)?;
-
                 let old_buf = std::fs::read_to_string(path)
                     .map_err(|e| crate::errors::Error::IoError(e, Some(path.to_owned())))?;
 
@@ -294,7 +293,6 @@ fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), crate
                     ));
                 }
             } else {
-                let schema = print_schema::output_schema(&mut connection, config)?;
                 std::fs::write(path, schema.as_bytes())
                     .map_err(|e| crate::errors::Error::IoError(e, Some(path.to_owned())))?;
             }
diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs
index 45bc06b90b1d..6882bf49c002 100644
--- a/diesel_cli/src/print_schema.rs
+++ b/diesel_cli/src/print_schema.rs
@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
 use std::collections::HashSet;
 use std::fmt::{self, Display, Formatter, Write};
 use std::io::Write as IoWrite;
+use std::process;
 
 const SCHEMA_HEADER: &str = "// @generated automatically by Diesel CLI.\n";
 
@@ -290,6 +291,53 @@ pub fn output_schema(
         out = diffy::apply(&out, &patch)?;
     }
 
+    match format_schema(&out) {
+        Ok(schema) => Ok(schema),
+        Err(err) => {
+            tracing::warn!(
+                "Couldn't format schema. Exporting unformatted schema ({:?})",
+                err
+            );
+            Ok(out)
+        }
+    }
+}
+
+pub fn format_schema(schema: &str) -> Result<String, crate::errors::Error> {
+    use crate::errors::Error;
+    // Inject schema through rustfmt stdin and get the formatted output
+    let mut child = process::Command::new("rustfmt")
+        .stdin(process::Stdio::piped())
+        .stdout(process::Stdio::piped())
+        .stderr(process::Stdio::piped())
+        .spawn()
+        .map_err(|err| Error::RustFmtFail(format!("Failed to launch child process ({})", err)))?;
+
+    {
+        let mut stdin = child
+            .stdin
+            .take()
+            .expect("we can always get the stdin from the child process");
+
+        stdin.write_all(schema.as_bytes()).map_err(|err| {
+            Error::RustFmtFail(format!("Failed to send schema to rustfmt ({})", err))
+        })?;
+        // the inner scope makes it so stdin gets dropped here
+    }
+
+    let output = child
+        .wait_with_output()
+        .map_err(|err| Error::RustFmtFail(format!("Couldn't wait for child ({})", err)))?;
+
+    // in cases rustfmt isn't installed, it will fail with
+    // 'error: 'rustfmt' is not installed for ...'
+    // this catches that error
+    if !output.status.success() {
+        let stderr = String::from_utf8(output.stderr).expect("rustfmt output is valid utf-8");
+        return Err(Error::RustFmtFail(format!("rustfmt error ({})", stderr)));
+    }
+
+    let out = String::from_utf8(output.stdout).expect("rustfmt output is valid utf-8");
     Ok(out)
 }
 
diff --git a/examples/postgres/advanced-blog-cli/src/schema.rs b/examples/postgres/advanced-blog-cli/src/schema.rs
index 15ba5ccc5d51..ee6346c63e2e 100644
--- a/examples/postgres/advanced-blog-cli/src/schema.rs
+++ b/examples/postgres/advanced-blog-cli/src/schema.rs
@@ -37,8 +37,4 @@ diesel::joinable!(comments -> posts (post_id));
 diesel::joinable!(comments -> users (user_id));
 diesel::joinable!(posts -> users (user_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    comments,
-    posts,
-    users,
-);
+diesel::allow_tables_to_appear_in_same_query!(comments, posts, users,);
diff --git a/examples/postgres/composite_types/src/schema.rs b/examples/postgres/composite_types/src/schema.rs
index a441a25b8104..16aeb18d58e3 100644
--- a/examples/postgres/composite_types/src/schema.rs
+++ b/examples/postgres/composite_types/src/schema.rs
@@ -18,7 +18,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    colors,
-    coordinates,
-);
+diesel::allow_tables_to_appear_in_same_query!(colors, coordinates,);
diff --git a/examples/postgres/relations/src/schema.rs b/examples/postgres/relations/src/schema.rs
index 10163ab9e0f1..4ca1214321a4 100644
--- a/examples/postgres/relations/src/schema.rs
+++ b/examples/postgres/relations/src/schema.rs
@@ -34,9 +34,4 @@ diesel::joinable!(books_authors -> authors (author_id));
 diesel::joinable!(books_authors -> books (book_id));
 diesel::joinable!(pages -> books (book_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    authors,
-    books,
-    books_authors,
-    pages,
-);
+diesel::allow_tables_to_appear_in_same_query!(authors, books, books_authors, pages,);
diff --git a/examples/sqlite/relations/src/schema.rs b/examples/sqlite/relations/src/schema.rs
index 68e8399f82f2..a4e38e66da1d 100644
--- a/examples/sqlite/relations/src/schema.rs
+++ b/examples/sqlite/relations/src/schema.rs
@@ -34,9 +34,4 @@ diesel::joinable!(books_authors -> authors (author_id));
 diesel::joinable!(books_authors -> books (book_id));
 diesel::joinable!(pages -> books (book_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    authors,
-    books,
-    books_authors,
-    pages,
-);
+diesel::allow_tables_to_appear_in_same_query!(authors, books, books_authors, pages,);


Test patch:
diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/mysql/schema_out.rs/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/mysql/schema_out.rs/expected.snap
index 0b082d11ad76..7b217ca9f082 100644
--- a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/mysql/schema_out.rs/expected.snap
+++ b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/mysql/schema_out.rs/expected.snap
@@ -23,8 +23,4 @@ diesel::table! {
 
 diesel::joinable!(posts -> users (user_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    posts,
-    users,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(posts, users,);
diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/postgres/schema_out.rs/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/postgres/schema_out.rs/expected.snap
index 093ac862c289..a874457a77f2 100644
--- a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/postgres/schema_out.rs/expected.snap
+++ b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/postgres/schema_out.rs/expected.snap
@@ -1,7 +1,7 @@
 ---
 source: diesel_cli/tests/migration_generate.rs
-assertion_line: 337
 description: "Test: diff_add_table_with_fk"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -23,8 +23,4 @@ diesel::table! {
 
 diesel::joinable!(posts -> users (user_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    posts,
-    users,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(posts, users,);
diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/sqlite/schema_out.rs/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/sqlite/schema_out.rs/expected.snap
index 1566564b2ee3..062eb570aaf0 100644
--- a/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/sqlite/schema_out.rs/expected.snap
+++ b/diesel_cli/tests/generate_migrations/diff_add_table_with_fk/sqlite/schema_out.rs/expected.snap
@@ -1,7 +1,7 @@
 ---
 source: diesel_cli/tests/migration_generate.rs
-assertion_line: 332
 description: "Test: diff_add_table_with_fk"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -23,8 +23,4 @@ diesel::table! {
 
 diesel::joinable!(posts -> users (user_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    posts,
-    users,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(posts, users,);
diff --git a/diesel_cli/tests/print_schema/print_schema_custom_types/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_custom_types/mysql/expected.snap
index 73e1f8195f46..d582e2912895 100644
--- a/diesel_cli/tests/print_schema/print_schema_custom_types/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_custom_types/mysql/expected.snap
@@ -22,8 +22,5 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 
diff --git a/diesel_cli/tests/print_schema/print_schema_custom_types/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_custom_types/postgres/expected.snap
index 235b609af140..5a5ce9bf60e2 100644
--- a/diesel_cli/tests/print_schema/print_schema_custom_types/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_custom_types/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_custom_types"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -22,8 +23,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_custom_types/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_custom_types/sqlite/expected.snap
index 181a364e3617..83db9964479f 100644
--- a/diesel_cli/tests/print_schema/print_schema_custom_types/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_custom_types/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_custom_types"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -22,8 +23,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_patch_file/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_patch_file/mysql/expected.snap
index e941df2adbac..36438a9f5839 100644
--- a/diesel_cli/tests/print_schema/print_schema_patch_file/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_patch_file/mysql/expected.snap
@@ -17,8 +17,5 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 
diff --git a/diesel_cli/tests/print_schema/print_schema_patch_file/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_patch_file/postgres/expected.snap
index 33894650d42d..a24ca3b2b1b0 100644
--- a/diesel_cli/tests/print_schema/print_schema_patch_file/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_patch_file/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_patch_file"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -17,8 +18,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_patch_file/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_patch_file/sqlite/expected.snap
index e941df2adbac..507d6c519ccb 100644
--- a/diesel_cli/tests/print_schema/print_schema_patch_file/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_patch_file/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_patch_file"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -17,8 +18,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_regression_3446_compound_keys/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_regression_3446_compound_keys/postgres/expected.snap
index ac72c0c75910..ce86cb5c7788 100644
--- a/diesel_cli/tests/print_schema/print_schema_regression_3446_compound_keys/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_regression_3446_compound_keys/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
-description: "Test: print_schema_regression_3446_ignore_compound_foreign_keys"
+description: "Test: print_schema_regression_3446_compound_keys"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -30,9 +31,4 @@ diesel::table! {
 
 diesel::joinable!(payment_card -> person (holder_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    payment_card,
-    person,
-    transaction,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(payment_card, person, transaction,);
diff --git a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/mysql/expected.snap
index 3f10f825657d..166e051936d5 100644
--- a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/mysql/expected.snap
@@ -19,8 +19,4 @@ diesel::table! {
 
 diesel::joinable!(tab_problem -> tab_key1 (key1));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    tab_key1,
-    tab_problem,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(tab_key1, tab_problem,);
diff --git a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/postgres/expected.snap
index a3a2b4a8ba49..666a95943e1c 100644
--- a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_regression_test_for_2623"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -19,8 +20,4 @@ diesel::table! {
 
 diesel::joinable!(tab_problem -> tab1 (key1));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    tab1,
-    tab_problem,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(tab1, tab_problem,);
diff --git a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.snap
index 5a991a6db3c8..9c49655779c1 100644
--- a/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_regression_test_for_2623"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -19,8 +20,4 @@ diesel::table! {
 
 diesel::joinable!(tab_problem -> tab_key1 (key1));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    tab_key1,
-    tab_problem,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(tab_key1, tab_problem,);
diff --git a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/mysql/expected.snap
index 5099596c0383..9c619cc71335 100644
--- a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/mysql/expected.snap
@@ -31,9 +31,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    payment_card,
-    transaction_one,
-    transaction_two,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(payment_card, transaction_one, transaction_two,);
diff --git a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/postgres/expected.snap
index 067422c1e2e8..b4124a5c1167 100644
--- a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_several_keys_with_compound_key"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -28,9 +29,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    payment_card,
-    transaction_one,
-    transaction_two,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(payment_card, transaction_one, transaction_two,);
diff --git a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/sqlite/expected.snap
index 607b4c75323b..bbcf3e0ff763 100644
--- a/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_several_keys_with_compound_key/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_several_keys_with_compound_key"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -28,9 +29,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    payment_card,
-    transaction_one,
-    transaction_two,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(payment_card, transaction_one, transaction_two,);
diff --git a/diesel_cli/tests/print_schema/print_schema_simple/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple/mysql/expected.snap
index 0336c8fba434..76a2dcd4ab84 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple/mysql/expected.snap
@@ -32,8 +32,5 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 
diff --git a/diesel_cli/tests/print_schema/print_schema_simple/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple/postgres/expected.snap
index 9b837d3a1a7a..a0819e8bc0e4 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_simple"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -32,8 +33,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_simple/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple/sqlite/expected.snap
index c0a7fbc136ba..7803d75669c8 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_simple"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -32,8 +33,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/mysql/expected.snap
index 391a15d80581..b775eb5d20b3 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/mysql/expected.snap
@@ -16,8 +16,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/postgres/expected.snap
index 50b382a223fc..4db7d2b8414a 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_simple_without_docs"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -16,8 +17,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/sqlite/expected.snap
index fc9bbc043ce1..4f223608cf9b 100644
--- a/diesel_cli/tests/print_schema/print_schema_simple_without_docs/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_simple_without_docs/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_simple_without_docs"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -16,8 +17,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
diff --git a/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_foreign_keys/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_foreign_keys/postgres/expected.snap
index 5662c8de19b6..5b31770e8999 100644
--- a/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_foreign_keys/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_foreign_keys/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_specifying_schema_name_with_foreign_keys"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -41,9 +42,5 @@ pub mod custom_schema {
 
     diesel::joinable!(b -> a (parent));
 
-    diesel::allow_tables_to_appear_in_same_query!(
-        a,
-        b,
-    );
+    diesel::allow_tables_to_appear_in_same_query!(a, b,);
 }
-
diff --git a/diesel_cli/tests/print_schema/print_schema_sqlite_implicit_foreign_key_reference/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_sqlite_implicit_foreign_key_reference/sqlite/expected.snap
index 9797ad601f27..fb9882f83bd2 100644
--- a/diesel_cli/tests/print_schema/print_schema_sqlite_implicit_foreign_key_reference/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_sqlite_implicit_foreign_key_reference/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_sqlite_implicit_foreign_key_reference"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -22,8 +23,4 @@ diesel::table! {
 
 diesel::joinable!(accounts -> data_centers (data_center_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    accounts,
-    data_centers,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(accounts, data_centers,);
diff --git a/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap
index 543c6a8a50df..cd6106e35b91 100644
--- a/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_sqlite_rowid_column"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -23,8 +24,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-    users3,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2, users3,);
diff --git a/diesel_cli/tests/print_schema/print_schema_table_order/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_table_order/mysql/expected.snap
index c1fe4cc91424..82de959431b2 100644
--- a/diesel_cli/tests/print_schema/print_schema_table_order/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_table_order/mysql/expected.snap
@@ -46,9 +46,5 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    abc,
-    def,
-    ghi,
-);
+diesel::allow_tables_to_appear_in_same_query!(abc, def, ghi,);
 
diff --git a/diesel_cli/tests/print_schema/print_schema_table_order/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_table_order/postgres/expected.snap
index ec3d99dbc9e0..e14db5ea83a1 100644
--- a/diesel_cli/tests/print_schema/print_schema_table_order/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_table_order/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_table_order"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -46,9 +47,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    abc,
-    def,
-    ghi,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(abc, def, ghi,);
diff --git a/diesel_cli/tests/print_schema/print_schema_table_order/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_table_order/sqlite/expected.snap
index 16052137f75c..9e69f085b556 100644
--- a/diesel_cli/tests/print_schema/print_schema_table_order/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_table_order/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_table_order"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -46,9 +47,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    abc,
-    def,
-    ghi,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(abc, def, ghi,);
diff --git a/diesel_cli/tests/print_schema/print_schema_unsigned/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_unsigned/mysql/expected.snap
index 25f9785f23b6..08f177f86b53 100644
--- a/diesel_cli/tests/print_schema/print_schema_unsigned/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_unsigned/mysql/expected.snap
@@ -38,8 +38,5 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 
diff --git a/diesel_cli/tests/print_schema/print_schema_with_compound_foreign_keys/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_compound_foreign_keys/postgres/expected.snap
index 912c006f7b88..a4ec47fcda65 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_compound_foreign_keys/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_compound_foreign_keys/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_compound_foreign_keys"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -56,8 +57,4 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    a,
-    b,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(a, b,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_foreign_keys/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_foreign_keys/postgres/expected.snap
index c0a3ef79df5d..637bfe1b7e82 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_foreign_keys/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_foreign_keys/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_foreign_keys"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -61,9 +62,4 @@ diesel::table! {
 diesel::joinable!(comments -> posts (post_id));
 diesel::joinable!(posts -> users (user_id));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    comments,
-    posts,
-    users,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(comments, posts, users,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_foreign_keys_reserved_names/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_foreign_keys_reserved_names/postgres/expected.snap
index 14f5fe4cc999..a7fab9e782fd 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_foreign_keys_reserved_names/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_foreign_keys_reserved_names/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_foreign_keys_reserved_names"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -41,8 +42,4 @@ diesel::table! {
 
 diesel::joinable!(posts -> users (type_));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    posts,
-    users,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(posts, users,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/mysql/expected.snap
index 64982a12d7fc..56098f1b63a8 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/mysql/expected.snap
@@ -17,10 +17,7 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 // @generated automatically by Diesel CLI.
 
 diesel::table! {
diff --git a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/postgres/expected.snap
index 4cf2e0348a4d..bda494dfa8b2 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_multiple_schema"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -16,10 +17,7 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 // @generated automatically by Diesel CLI.
 
 diesel::table! {
@@ -50,4 +48,3 @@ diesel::table! {
         id -> Int4,
     }
 }
-
diff --git a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/sqlite/expected.snap
index 8dc866e3d2c0..523a3e6f5a6a 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_multiple_schema/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_multiple_schema"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -16,10 +17,7 @@ diesel::table! {
     }
 }
 
-diesel::allow_tables_to_appear_in_same_query!(
-    users1,
-    users2,
-);
+diesel::allow_tables_to_appear_in_same_query!(users1, users2,);
 // @generated automatically by Diesel CLI.
 
 diesel::table! {
@@ -50,4 +48,3 @@ diesel::table! {
         id -> Nullable<Integer>,
     }
 }
-
diff --git a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/mysql/expected.snap
index fd6b753b9ed9..740bfc55febf 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/mysql/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/mysql/expected.snap
@@ -62,8 +62,4 @@ diesel::table! {
 
 diesel::joinable!(user_has_complex_role -> self_ (user));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    self_,
-    user_has_complex_role,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(self_, user_has_complex_role,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/postgres/expected.snap
index d590c1244553..64c9b47870a8 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_unmappable_names"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -62,8 +63,4 @@ diesel::table! {
 
 diesel::joinable!(user_has_complex_role -> self_ (user));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    self_,
-    user_has_complex_role,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(self_, user_has_complex_role,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/sqlite/expected.snap
index fd6b753b9ed9..a944d70a9eec 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/sqlite/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names/sqlite/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_unmappable_names"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -62,8 +63,4 @@ diesel::table! {
 
 diesel::joinable!(user_has_complex_role -> self_ (user));
 
-diesel::allow_tables_to_appear_in_same_query!(
-    self_,
-    user_has_complex_role,
-);
-
+diesel::allow_tables_to_appear_in_same_query!(self_, user_has_complex_role,);
diff --git a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names_and_schema_name/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names_and_schema_name/postgres/expected.snap
index 11af2cd2d750..e7eae7eae0d2 100644
--- a/diesel_cli/tests/print_schema/print_schema_with_unmappable_names_and_schema_name/postgres/expected.snap
+++ b/diesel_cli/tests/print_schema/print_schema_with_unmappable_names_and_schema_name/postgres/expected.snap
@@ -1,6 +1,7 @@
 ---
 source: diesel_cli/tests/print_schema.rs
 description: "Test: print_schema_with_unmappable_names_and_schema_name"
+snapshot_kind: text
 ---
 // @generated automatically by Diesel CLI.
 
@@ -63,9 +64,5 @@ pub mod custom_schema {
 
     diesel::joinable!(user_has_complex_role -> self_ (user));
 
-    diesel::allow_tables_to_appear_in_same_query!(
-        self_,
-        user_has_complex_role,
-    );
+    diesel::allow_tables_to_appear_in_same_query!(self_, user_has_complex_role,);
 }
-