Skip to content

Commit d7bfd0d

Browse files
committed
remove imports from $table_name module
1 parent e0fd9cc commit d7bfd0d

1 file changed

Lines changed: 49 additions & 54 deletions

File tree

diesel/src/macros/mod.rs

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,7 @@ macro_rules! __diesel_table_impl {
613613
Table,
614614
JoinTo,
615615
};
616-
use $crate::associations::HasTable;
617-
use $crate::insertable::Insertable;
618-
use $crate::query_builder::*;
619-
use $crate::query_builder::nodes::Identifier;
620-
use $crate::query_source::{AppearsInFromClause, Once, Never};
621-
use $crate::query_source::joins::{Join, JoinOn};
616+
use $crate::query_builder::AsQuery;
622617
$($imports)*
623618
pub use self::columns::*;
624619

@@ -672,16 +667,16 @@ macro_rules! __diesel_table_impl {
672667
pub type SqlType = ($($($column_ty)*,)+);
673668

674669
/// Helper type for representing a boxed query from this table
675-
pub type BoxedQuery<'a, DB, ST = SqlType> = BoxedSelectStatement<'a, ST, table, DB>;
670+
pub type BoxedQuery<'a, DB, ST = SqlType> = $crate::query_builder::BoxedSelectStatement<'a, ST, table, DB>;
676671

677672
$crate::__diesel_table_query_source_impl!(table, $schema, $sql_name);
678673

679-
impl AsQuery for table {
674+
impl $crate::query_builder::AsQuery for table {
680675
type SqlType = SqlType;
681-
type Query = SelectStatement<Self>;
676+
type Query = $crate::query_builder::SelectStatement<Self>;
682677

683678
fn as_query(self) -> Self::Query {
684-
SelectStatement::simple(self)
679+
$crate::query_builder::SelectStatement::simple(self)
685680
}
686681
}
687682

@@ -698,95 +693,95 @@ macro_rules! __diesel_table_impl {
698693
}
699694
}
700695

701-
impl HasTable for table {
696+
impl $crate::associations::HasTable for table {
702697
type Table = Self;
703698

704699
fn table() -> Self::Table {
705700
table
706701
}
707702
}
708703

709-
impl IntoUpdateTarget for table {
710-
type WhereClause = <<Self as AsQuery>::Query as IntoUpdateTarget>::WhereClause;
704+
impl $crate::query_builder::IntoUpdateTarget for table {
705+
type WhereClause = <<Self as $crate::query_builder::AsQuery>::Query as $crate::query_builder::IntoUpdateTarget>::WhereClause;
711706

712-
fn into_update_target(self) -> UpdateTarget<Self::Table, Self::WhereClause> {
707+
fn into_update_target(self) -> $crate::query_builder::UpdateTarget<Self::Table, Self::WhereClause> {
713708
self.as_query().into_update_target()
714709
}
715710
}
716711

717-
impl AppearsInFromClause<table> for table {
718-
type Count = Once;
712+
impl $crate::query_source::AppearsInFromClause<table> for table {
713+
type Count = $crate::query_source::Once;
719714
}
720715

721-
impl AppearsInFromClause<table> for () {
722-
type Count = Never;
716+
impl $crate::query_source::AppearsInFromClause<table> for () {
717+
type Count = $crate::query_source::Never;
723718
}
724719

725-
impl<Left, Right, Kind> JoinTo<Join<Left, Right, Kind>> for table where
726-
Join<Left, Right, Kind>: JoinTo<table>,
720+
impl<Left, Right, Kind> JoinTo<$crate::query_source::joins::Join<Left, Right, Kind>> for table where
721+
$crate::query_source::joins::Join<Left, Right, Kind>: JoinTo<table>,
727722
{
728-
type FromClause = Join<Left, Right, Kind>;
729-
type OnClause = <Join<Left, Right, Kind> as JoinTo<table>>::OnClause;
723+
type FromClause = $crate::query_source::joins::Join<Left, Right, Kind>;
724+
type OnClause = <$crate::query_source::joins::Join<Left, Right, Kind> as JoinTo<table>>::OnClause;
730725

731-
fn join_target(rhs: Join<Left, Right, Kind>) -> (Self::FromClause, Self::OnClause) {
732-
let (_, on_clause) = Join::join_target(table);
726+
fn join_target(rhs: $crate::query_source::joins::Join<Left, Right, Kind>) -> (Self::FromClause, Self::OnClause) {
727+
let (_, on_clause) = $crate::query_source::joins::Join::join_target(table);
733728
(rhs, on_clause)
734729
}
735730
}
736731

737-
impl<Join, On> JoinTo<JoinOn<Join, On>> for table where
738-
JoinOn<Join, On>: JoinTo<table>,
732+
impl<Join, On> JoinTo<$crate::query_source::joins::JoinOn<Join, On>> for table where
733+
$crate::query_source::joins::JoinOn<Join, On>: JoinTo<table>,
739734
{
740-
type FromClause = JoinOn<Join, On>;
741-
type OnClause = <JoinOn<Join, On> as JoinTo<table>>::OnClause;
735+
type FromClause = $crate::query_source::joins::JoinOn<Join, On>;
736+
type OnClause = <$crate::query_source::joins::JoinOn<Join, On> as JoinTo<table>>::OnClause;
742737

743-
fn join_target(rhs: JoinOn<Join, On>) -> (Self::FromClause, Self::OnClause) {
744-
let (_, on_clause) = JoinOn::join_target(table);
738+
fn join_target(rhs: $crate::query_source::joins::JoinOn<Join, On>) -> (Self::FromClause, Self::OnClause) {
739+
let (_, on_clause) = $crate::query_source::joins::JoinOn::join_target(table);
745740
(rhs, on_clause)
746741
}
747742
}
748743

749-
impl<F, S, D, W, O, L, Of, G> JoinTo<SelectStatement<F, S, D, W, O, L, Of, G>> for table where
750-
SelectStatement<F, S, D, W, O, L, Of, G>: JoinTo<table>,
744+
impl<F, S, D, W, O, L, Of, G> JoinTo<$crate::query_builder::SelectStatement<F, S, D, W, O, L, Of, G>> for table where
745+
$crate::query_builder::SelectStatement<F, S, D, W, O, L, Of, G>: JoinTo<table>,
751746
{
752-
type FromClause = SelectStatement<F, S, D, W, O, L, Of, G>;
753-
type OnClause = <SelectStatement<F, S, D, W, O, L, Of, G> as JoinTo<table>>::OnClause;
747+
type FromClause = $crate::query_builder::SelectStatement<F, S, D, W, O, L, Of, G>;
748+
type OnClause = <$crate::query_builder::SelectStatement<F, S, D, W, O, L, Of, G> as JoinTo<table>>::OnClause;
754749

755-
fn join_target(rhs: SelectStatement<F, S, D, W, O, L, Of, G>) -> (Self::FromClause, Self::OnClause) {
756-
let (_, on_clause) = SelectStatement::join_target(table);
750+
fn join_target(rhs: $crate::query_builder::SelectStatement<F, S, D, W, O, L, Of, G>) -> (Self::FromClause, Self::OnClause) {
751+
let (_, on_clause) = $crate::query_builder::SelectStatement::join_target(table);
757752
(rhs, on_clause)
758753
}
759754
}
760755

761-
impl<'a, QS, ST, DB> JoinTo<BoxedSelectStatement<'a, QS, ST, DB>> for table where
762-
BoxedSelectStatement<'a, QS, ST, DB>: JoinTo<table>,
756+
impl<'a, QS, ST, DB> JoinTo<$crate::query_builder::BoxedSelectStatement<'a, QS, ST, DB>> for table where
757+
$crate::query_builder::BoxedSelectStatement<'a, QS, ST, DB>: JoinTo<table>,
763758
{
764-
type FromClause = BoxedSelectStatement<'a, QS, ST, DB>;
765-
type OnClause = <BoxedSelectStatement<'a, QS, ST, DB> as JoinTo<table>>::OnClause;
766-
fn join_target(rhs: BoxedSelectStatement<'a, QS, ST, DB>) -> (Self::FromClause, Self::OnClause) {
767-
let (_, on_clause) = BoxedSelectStatement::join_target(table);
759+
type FromClause = $crate::query_builder::BoxedSelectStatement<'a, QS, ST, DB>;
760+
type OnClause = <$crate::query_builder::BoxedSelectStatement<'a, QS, ST, DB> as JoinTo<table>>::OnClause;
761+
fn join_target(rhs: $crate::query_builder::BoxedSelectStatement<'a, QS, ST, DB>) -> (Self::FromClause, Self::OnClause) {
762+
let (_, on_clause) = $crate::query_builder::BoxedSelectStatement::join_target(table);
768763
(rhs, on_clause)
769764
}
770765
}
771766

772767
// This impl should be able to live in Diesel,
773768
// but Rust tries to recurse for no reason
774-
impl<T> Insertable<T> for table
769+
impl<T> $crate::insertable::Insertable<T> for table
775770
where
776-
<table as AsQuery>::Query: Insertable<T>,
771+
<table as $crate::query_builder::AsQuery>::Query: $crate::insertable::Insertable<T>,
777772
{
778-
type Values = <<table as AsQuery>::Query as Insertable<T>>::Values;
773+
type Values = <<table as $crate::query_builder::AsQuery>::Query as $crate::insertable::Insertable<T>>::Values;
779774

780775
fn values(self) -> Self::Values {
781776
self.as_query().values()
782777
}
783778
}
784779

785-
impl<'a, T> Insertable<T> for &'a table
780+
impl<'a, T> $crate::insertable::Insertable<T> for &'a table
786781
where
787-
table: Insertable<T>,
782+
table: $crate::insertable::Insertable<T>,
788783
{
789-
type Values = <table as Insertable<T>>::Values;
784+
type Values = <table as $crate::insertable::Insertable<T>>::Values;
790785

791786
fn values(self) -> Self::Values {
792787
(*self).values()
@@ -857,11 +852,11 @@ macro_rules! __diesel_table_impl {
857852
macro_rules! __diesel_table_query_source_impl {
858853
($table_struct:ident, public, $table_name:expr) => {
859854
impl QuerySource for $table_struct {
860-
type FromClause = Identifier<'static>;
855+
type FromClause = $crate::query_builder::nodes::Identifier<'static>;
861856
type DefaultSelection = <Self as Table>::AllColumns;
862857

863858
fn from_clause(&self) -> Self::FromClause {
864-
Identifier($table_name)
859+
$crate::query_builder::nodes::Identifier($table_name)
865860
}
866861

867862
fn default_selection(&self) -> Self::DefaultSelection {
@@ -874,15 +869,15 @@ macro_rules! __diesel_table_query_source_impl {
874869
impl QuerySource for $table_struct {
875870
type FromClause = $crate::query_builder::nodes::InfixNode<
876871
'static,
877-
Identifier<'static>,
878-
Identifier<'static>,
872+
$crate::query_builder::nodes::Identifier<'static>,
873+
$crate::query_builder::nodes::Identifier<'static>,
879874
>;
880875
type DefaultSelection = <Self as Table>::AllColumns;
881876

882877
fn from_clause(&self) -> Self::FromClause {
883878
$crate::query_builder::nodes::InfixNode::new(
884-
Identifier(stringify!($schema_name)),
885-
Identifier($table_name),
879+
$crate::query_builder::nodes::Identifier(stringify!($schema_name)),
880+
$crate::query_builder::nodes::Identifier($table_name),
886881
".",
887882
)
888883
}

0 commit comments

Comments
 (0)