@@ -3,10 +3,7 @@ use crate::connection::Connection;
33use crate :: describe:: Describe ;
44use crate :: error:: Error ;
55use crate :: executor:: { Execute , Executor } ;
6- use crate :: snowflake:: {
7- Snowflake , SnowflakeArguments , SnowflakeConnectOptions , SnowflakeQueryResult , SnowflakeRow ,
8- SnowflakeStatement , SnowflakeTransactionManager , SnowflakeTypeInfo ,
9- } ;
6+ use crate :: snowflake:: { Snowflake , SnowflakeConnectOptions , SnowflakeQueryResult , SnowflakeStatement } ;
107use crate :: transaction:: Transaction ;
118use either:: Either ;
129use futures_core:: future:: BoxFuture ;
@@ -42,7 +39,11 @@ impl Debug for SnowflakeConnection {
4239impl SnowflakeConnection {
4340 pub ( crate ) async fn establish ( options : & SnowflakeConnectOptions ) -> Result < Self , Error > {
4441 let client = reqwest:: Client :: builder ( )
45- . timeout ( options. timeout . unwrap_or ( std:: time:: Duration :: from_secs ( 30 ) ) )
42+ . timeout (
43+ options
44+ . timeout
45+ . unwrap_or ( std:: time:: Duration :: from_secs ( 30 ) ) ,
46+ )
4647 . user_agent ( "SQLx-Snowflake/0.6.48" )
4748 . build ( )
4849 . map_err ( |e| Error :: Configuration ( e. into ( ) ) ) ?;
@@ -70,7 +71,7 @@ impl SnowflakeConnection {
7071 async fn authenticate ( & mut self ) -> Result < ( ) , Error > {
7172 // For now, implement username/password authentication
7273 // TODO: Implement JWT authentication with private key
73-
74+
7475 if self . options . username . is_empty ( ) {
7576 return Err ( Error :: Configuration (
7677 "Username is required for Snowflake authentication" . into ( ) ,
@@ -81,7 +82,7 @@ impl SnowflakeConnection {
8182 // In a real implementation, this would use RSA private keys
8283 let token = self . generate_jwt_token ( ) ?;
8384 self . auth_token = Some ( token) ;
84-
85+
8586 Ok ( ( ) )
8687 }
8788
@@ -123,7 +124,9 @@ impl SnowflakeConnection {
123124 pub ( crate ) async fn execute ( & mut self , query : & str ) -> Result < SnowflakeQueryResult , Error > {
124125 use serde_json:: json;
125126
126- let auth_token = self . auth_token . as_ref ( )
127+ let auth_token = self
128+ . auth_token
129+ . as_ref ( )
127130 . ok_or_else ( || Error :: Configuration ( "Not authenticated" . into ( ) ) ) ?;
128131
129132 let request_body = json ! ( {
@@ -135,29 +138,36 @@ impl SnowflakeConnection {
135138 "role" : self . options. role
136139 } ) ;
137140
138- let response = self . client
141+ let response = self
142+ . client
139143 . post ( & self . base_url )
140144 . header ( "Authorization" , format ! ( "Bearer {}" , auth_token) )
141145 . header ( "Content-Type" , "application/json" )
142146 . header ( "Accept" , "application/json" )
143147 . json ( & request_body)
144148 . send ( )
145149 . await
146- . map_err ( |e| Error :: Io ( std:: io:: Error :: new ( std :: io :: ErrorKind :: Other , e) ) ) ?;
150+ . map_err ( |e| Error :: Io ( std:: io:: Error :: other ( e) ) ) ?;
147151
148152 if !response. status ( ) . is_success ( ) {
149153 let status = response. status ( ) ;
150- let error_text = response. text ( ) . await
154+ let error_text = response
155+ . text ( )
156+ . await
151157 . unwrap_or_else ( |_| "Unknown error" . to_string ( ) ) ;
152- return Err ( Error :: Database ( Box :: new ( crate :: snowflake:: SnowflakeDatabaseError :: new (
153- status. as_u16 ( ) . to_string ( ) ,
154- format ! ( "HTTP {}: {}" , status, error_text) ,
155- None ,
156- ) ) ) ) ;
158+ return Err ( Error :: Database ( Box :: new (
159+ crate :: snowflake:: SnowflakeDatabaseError :: new (
160+ status. as_u16 ( ) . to_string ( ) ,
161+ format ! ( "HTTP {}: {}" , status, error_text) ,
162+ None ,
163+ ) ,
164+ ) ) ) ;
157165 }
158166
159- let response_json: serde_json:: Value = response. json ( ) . await
160- . map_err ( |e| Error :: Io ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , e) ) ) ?;
167+ let response_json: serde_json:: Value = response
168+ . json ( )
169+ . await
170+ . map_err ( |e| Error :: Io ( std:: io:: Error :: other ( e) ) ) ?;
161171
162172 // Parse the response to extract row count and other metadata
163173 let rows_affected = response_json
@@ -234,11 +244,14 @@ impl<'c> Executor<'c> for &'c mut SnowflakeConnection {
234244
235245 fn fetch_many < ' e , ' q : ' e , E > (
236246 self ,
237- query : E ,
247+ _query : E ,
238248 ) -> BoxStream <
239249 ' e ,
240250 Result <
241- Either < <Self :: Database as crate :: database:: Database >:: QueryResult , <Self :: Database as crate :: database:: Database >:: Row > ,
251+ Either <
252+ <Self :: Database as crate :: database:: Database >:: QueryResult ,
253+ <Self :: Database as crate :: database:: Database >:: Row ,
254+ > ,
242255 Error ,
243256 > ,
244257 >
@@ -253,7 +266,7 @@ impl<'c> Executor<'c> for &'c mut SnowflakeConnection {
253266
254267 fn fetch_optional < ' e , ' q : ' e , E > (
255268 self ,
256- query : E ,
269+ _query : E ,
257270 ) -> BoxFuture < ' e , Result < Option < <Self :: Database as crate :: database:: Database >:: Row > , Error > >
258271 where
259272 ' c : ' e ,
@@ -270,7 +283,10 @@ impl<'c> Executor<'c> for &'c mut SnowflakeConnection {
270283 self ,
271284 sql : & ' q str ,
272285 parameters : & ' e [ <Self :: Database as crate :: database:: Database >:: TypeInfo ] ,
273- ) -> BoxFuture < ' e , Result < <Self :: Database as crate :: database:: HasStatement < ' q > >:: Statement , Error > >
286+ ) -> BoxFuture <
287+ ' e ,
288+ Result < <Self :: Database as crate :: database:: HasStatement < ' q > >:: Statement , Error > ,
289+ >
274290 where
275291 ' c : ' e ,
276292 {
@@ -288,7 +304,7 @@ impl<'c> Executor<'c> for &'c mut SnowflakeConnection {
288304
289305 fn describe < ' e , ' q : ' e > (
290306 self ,
291- sql : & ' q str ,
307+ _sql : & ' q str ,
292308 ) -> BoxFuture < ' e , Result < Describe < Self :: Database > , Error > >
293309 where
294310 ' c : ' e ,
@@ -303,4 +319,4 @@ impl<'c> Executor<'c> for &'c mut SnowflakeConnection {
303319 } )
304320 } )
305321 }
306- }
322+ }
0 commit comments