@@ -4,18 +4,15 @@ use quote::quote;
44
55use sqlx_macros_core:: * ;
66
7- /// Constant used in all macros to define the root crate .
7+ /// Constant used in all macros to define the macros namespace .
88/// This accommodates 3rd party drivers by allowing them to specify a different
99/// root crate that paths used with proc macros resolve to.
1010#[ cfg( not( test) ) ]
1111const CRATE_NAME : & str = "sqlx" ;
12- // Allows for easier testing of the configurable root crate feature
12+ // Allows for easier testing of the configurable macros namespace feature
1313// of current proc macros without duplicating them.
1414#[ cfg( test) ]
15- const CRATE_NAME : & str = match option_env ! ( "SQLX_ROOT_CRATE" ) {
16- Some ( c) => c,
17- None => "sqlx" ,
18- } ;
15+ const CRATE_NAME : & str = env ! ( "SQLX_NAMESPACE" ) ;
1916
2017#[ cfg( feature = "macros" ) ]
2118#[ proc_macro]
@@ -112,3 +109,31 @@ pub fn test(args: TokenStream, input: TokenStream) -> TokenStream {
112109 }
113110 }
114111}
112+
113+ #[ cfg( test) ]
114+ mod tests {
115+ #[ test]
116+ #[ cfg( feature = "migrate" ) ]
117+ fn test_macros_namespace_migrate ( ) {
118+ /// Import as different namespace.
119+ ///
120+ /// This must be set as `SQLX_NAMESPACE` environment variable to test that
121+ /// changing the namespace still results in the proc macros behaving well.
122+ extern crate sqlx as external;
123+
124+ let _ = external:: migrate!( "../tests/migrate/migrations_simple" ) ;
125+ }
126+
127+ #[ test]
128+ #[ cfg( feature = "derive" ) ]
129+ fn test_macros_namespace_derive ( ) {
130+ /// Import as different namespace.
131+ ///
132+ /// This must be set as `SQLX_NAMESPACE` environment variable to test that
133+ /// changing the namespace still results in the proc macros behaving well.
134+ extern crate sqlx as external;
135+
136+ #[ derive( Debug , external:: Type , external:: Encode , external:: Decode , external:: FromRow ) ]
137+ struct Test { }
138+ }
139+ }
0 commit comments