From 775ffa953009bfd6a90c7440ff5c38500195ca7d Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Fri, 27 Nov 2020 08:15:11 +0000 Subject: [PATCH] Allow re-exporting diesel in other libs --- diesel/src/macros/mod.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/diesel/src/macros/mod.rs b/diesel/src/macros/mod.rs index 90bdaf33bca9..1f6fd8caf04a 100644 --- a/diesel/src/macros/mod.rs +++ b/diesel/src/macros/mod.rs @@ -23,9 +23,15 @@ macro_rules! __diesel_column { ) => { $($meta)* #[allow(non_camel_case_types, dead_code)] - #[derive(Debug, Clone, Copy, $crate::query_builder::QueryId, Default)] + #[derive(Debug, Clone, Copy, Default)] pub struct $column_name; + #[allow(non_camel_case_types)] + impl $crate::query_builder::QueryId for $column_name { + type QueryId = $column_name; + const HAS_STATIC_QUERY_ID: bool = true; + } + impl $crate::expression::Expression for $column_name { type SqlType = $($Type)*; } @@ -653,13 +659,19 @@ macro_rules! __diesel_table_impl { pub const all_columns: ($($column_name,)+) = ($($column_name,)+); #[allow(non_camel_case_types)] - #[derive(Debug, Clone, Copy, $crate::query_builder::QueryId)] + #[derive(Debug, Clone, Copy)] /// The actual table struct /// /// This is the type which provides the base methods of the query /// builder, such as `.select` and `.filter`. pub struct table; + #[allow(non_camel_case_types)] + impl $crate::query_builder::QueryId for table { + type QueryId = table; + const HAS_STATIC_QUERY_ID: bool = true; + } + impl table { #[allow(dead_code)] /// Represents `table_name.*`, which is sometimes necessary @@ -803,13 +815,19 @@ macro_rules! __diesel_table_impl { $($imports)* #[allow(non_camel_case_types, dead_code)] - #[derive(Debug, Clone, Copy, $crate::query_builder::QueryId)] + #[derive(Debug, Clone, Copy)] /// Represents `table_name.*`, which is sometimes needed for /// efficient count queries. It cannot be used in place of /// `all_columns`, and has a `SqlType` of `()` to prevent it /// being used that way pub struct star; + #[allow(non_camel_case_types)] + impl $crate::query_builder::QueryId for star { + type QueryId = star; + const HAS_STATIC_QUERY_ID: bool = true; + } + impl<__GB> $crate::expression::ValidGrouping<__GB> for star where ($($column_name,)+): $crate::expression::ValidGrouping<__GB>,