-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add print-schema option
allow_tables_in_same_query
- Loading branch information
Showing
8 changed files
with
246 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
diesel_cli/tests/print_schema/print_schema_allow_tables_in_same_query/diesel.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[print_schema] | ||
file = "src/schema.rs" | ||
allow_tables_in_same_query = "fk_related_tables" |
59 changes: 59 additions & 0 deletions
59
diesel_cli/tests/print_schema/print_schema_allow_tables_in_same_query/postgres/expected.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
source: diesel_cli/tests/print_schema.rs | ||
assertion_line: 500 | ||
description: "Test: print_schema_allow_tables_in_same_query" | ||
snapshot_kind: text | ||
--- | ||
// @generated automatically by Diesel CLI. | ||
|
||
diesel::table! { | ||
bikes (id) { | ||
id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
cars (id) { | ||
id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
comments (id) { | ||
id -> Int4, | ||
post_id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
posts (id) { | ||
id -> Int4, | ||
user_id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
sessions (id) { | ||
id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
transactions (id) { | ||
id -> Int4, | ||
session_id -> Int4, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
users (id) { | ||
id -> Int4, | ||
} | ||
} | ||
|
||
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,); |
12 changes: 12 additions & 0 deletions
12
diesel_cli/tests/print_schema/print_schema_allow_tables_in_same_query/postgres/schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Three related tables. | ||
CREATE TABLE users (id SERIAL PRIMARY KEY); | ||
CREATE TABLE posts (id SERIAL PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users); | ||
CREATE TABLE comments (id SERIAL PRIMARY KEY, post_id INTEGER NOT NULL REFERENCES posts); | ||
|
||
-- Two related tables. | ||
CREATE TABLE sessions (id SERIAL PRIMARY KEY); | ||
CREATE TABLE transactions (id SERIAL PRIMARY KEY, session_id INTEGER NOT NULL REFERENCES sessions); | ||
|
||
-- Unrelated tables. | ||
CREATE TABLE cars (id SERIAL PRIMARY KEY); | ||
CREATE TABLE bikes (id SERIAL PRIMARY KEY); |