Skip to content

Commit f23b0eb

Browse files
Rename enable_multi_table_joins! to allow_tables_to_appear_in_same_query!
1 parent 0de63ae commit f23b0eb

9 files changed

Lines changed: 29 additions & 21 deletions

File tree

diesel/src/macros/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,14 @@ macro_rules! joinable_inner {
965965
}
966966
}
967967

968+
#[deprecated(since = "0.16.0", note = "use `allow_tables_to_appear_in_same_query!` instead")]
969+
#[macro_export]
970+
macro_rules! enable_multi_table_joins {
971+
($left_mod:ident, $right_mod:ident) => {
972+
enable_multi_table_joins!($left_mod, $right_mod);
973+
}
974+
}
975+
968976
/// Allow two tables which are otherwise unrelated to be used together in a
969977
/// multi-table join. This macro only needs to be invoked when the two tables
970978
/// don't have an association between them (e.g. parent to grandchild)
@@ -978,7 +986,7 @@ macro_rules! joinable_inner {
978986
/// enable_multi_table_joins!(users, comments);
979987
/// ```
980988
#[macro_export]
981-
macro_rules! enable_multi_table_joins {
989+
macro_rules! allow_tables_to_appear_in_same_query {
982990
($left_mod:ident, $right_mod:ident) => {
983991
impl $crate::query_source::AppearsInFromClause<$left_mod::table>
984992
for $right_mod::table

diesel/src/query_dsl/join_dsl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ where
5555
/// and we do not currently have a fleshed out story for dealing with table
5656
/// aliases.
5757
///
58-
/// You may also need to call [`enable_multi_table_joins!`][] (particularly if
58+
/// You may also need to call [`allow_tables_to_appear_in_same_query!`][] (particularly if
5959
/// you see an unexpected error about `AppearsInFromClause`). See the
60-
/// documentation for [`enable_multi_table_joins!`][] for details.
60+
/// documentation for [`allow_tables_to_appear_in_same_query!`][] for details.
6161
///
6262
/// Diesel expects multi-table joins to be semantically grouped based on the
6363
/// relationships. For example, `users.inner_join(posts.inner_join(comments))`
@@ -81,7 +81,7 @@ where
8181
/// ```
8282
///
8383
/// [associations]: ../associations/index.html
84-
/// [`enable_multi_table_joins!`]: ../macro.enable_multi_table_joins.html
84+
/// [`allow_tables_to_appear_in_same_query!`]: ../macro.allow_tables_to_appear_in_same_query.html
8585
pub trait JoinDsl: Sized {
8686
/// Join two tables using a SQL `INNER JOIN`. The `ON` clause is defined
8787
/// via the [associations API](../associations/index.html).
@@ -137,7 +137,7 @@ pub trait JoinOnDsl: Sized {
137137
/// # }
138138
/// # }
139139
/// #
140-
/// # enable_multi_table_joins!(users, posts);
140+
/// # allow_tables_to_appear_in_same_query!(users, posts);
141141
/// #
142142
/// # fn main() {
143143
/// # let connection = establish_connection();

diesel_compile_tests/tests/compile-fail/cannot_join_to_non_joinable_table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ table! {
2525
}
2626

2727
joinable!(comments -> posts (post_id));
28-
enable_multi_table_joins!(users, posts);
29-
enable_multi_table_joins!(users, comments);
28+
allow_tables_to_appear_in_same_query!(users, posts);
29+
allow_tables_to_appear_in_same_query!(users, comments);
3030

3131
fn main() {
3232
let _ = users::table.inner_join(posts::table);

diesel_compile_tests/tests/compile-fail/filter_cannot_take_comparison_for_columns_from_another_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ table! {
1818
}
1919
}
2020

21-
enable_multi_table_joins!(users, posts);
21+
allow_tables_to_appear_in_same_query!(users, posts);
2222

2323
#[derive(Queryable)]
2424
struct User {

diesel_compile_tests/tests/compile-fail/join_with_explicit_on_requires_valid_boolean_expression.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ table! {
2020
}
2121
}
2222

23-
enable_multi_table_joins!(users, posts);
24-
enable_multi_table_joins!(users, comments);
25-
enable_multi_table_joins!(posts, comments);
23+
allow_tables_to_appear_in_same_query!(users, posts);
24+
allow_tables_to_appear_in_same_query!(users, comments);
25+
allow_tables_to_appear_in_same_query!(posts, comments);
2626

2727
fn main() {
2828
// Sanity check, make sure valid joins compile

diesel_compile_tests/tests/compile-fail/subselect_cannot_reference_random_tables.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ table! {
2121
}
2222
}
2323

24-
enable_multi_table_joins!(users, posts);
25-
enable_multi_table_joins!(users, comments);
26-
enable_multi_table_joins!(posts, comments);
24+
allow_tables_to_appear_in_same_query!(users, posts);
25+
allow_tables_to_appear_in_same_query!(users, comments);
26+
allow_tables_to_appear_in_same_query!(posts, comments);
2727

2828
fn main() {
2929
use diesel::dsl::{any, exists};

diesel_infer_schema/src/information_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ mod information_schema {
112112
}
113113
}
114114

115-
enable_multi_table_joins!(table_constraints, referential_constraints);
116-
enable_multi_table_joins!(key_column_usage, table_constraints);
115+
allow_tables_to_appear_in_same_query!(table_constraints, referential_constraints);
116+
allow_tables_to_appear_in_same_query!(key_column_usage, table_constraints);
117117
}
118118

119119
pub fn get_table_data<Conn>(conn: &Conn, table: &TableName) -> QueryResult<Vec<ColumnInformation>>

diesel_infer_schema/src/mysql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod information_schema {
2929
}
3030
}
3131

32-
enable_multi_table_joins!(table_constraints, key_column_usage);
32+
allow_tables_to_appear_in_same_query!(table_constraints, key_column_usage);
3333
}
3434

3535
/// Even though this is using `information_schema`, MySQL needs non-ANSI columns

diesel_tests/tests/schema.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub fn find_user_by_name(name: &str, connection: &TestConnection) -> User {
301301
.unwrap()
302302
}
303303

304-
enable_multi_table_joins!(users, comments);
305-
enable_multi_table_joins!(posts, likes);
306-
enable_multi_table_joins!(followings, likes);
307-
enable_multi_table_joins!(followings, comments);
304+
allow_tables_to_appear_in_same_query!(users, comments);
305+
allow_tables_to_appear_in_same_query!(posts, likes);
306+
allow_tables_to_appear_in_same_query!(followings, likes);
307+
allow_tables_to_appear_in_same_query!(followings, comments);

0 commit comments

Comments
 (0)