@@ -5,7 +5,7 @@ use std::thread;
55
66use futures_channel:: oneshot;
77use futures_intrusive:: sync:: { Mutex , MutexGuard } ;
8- use sqlx_core:: sql_str:: { AssertSqlSafe , SqlSafeStr } ;
8+ use sqlx_core:: sql_str:: SqlStr ;
99use tracing:: span:: Span ;
1010
1111use sqlx_core:: describe:: Describe ;
@@ -42,15 +42,15 @@ pub(crate) struct WorkerSharedState {
4242
4343enum Command {
4444 Prepare {
45- query : Box < str > ,
45+ query : SqlStr ,
4646 tx : oneshot:: Sender < Result < SqliteStatement , Error > > ,
4747 } ,
4848 Describe {
49- query : Box < str > ,
49+ query : SqlStr ,
5050 tx : oneshot:: Sender < Result < Describe < Sqlite > , Error > > ,
5151 } ,
5252 Execute {
53- query : Box < str > ,
53+ query : SqlStr ,
5454 arguments : Option < SqliteArguments < ' static > > ,
5555 persistent : bool ,
5656 tx : flume:: Sender < Result < Either < SqliteQueryResult , SqliteRow > , Error > > ,
@@ -132,7 +132,7 @@ impl ConnectionWorker {
132132 let _guard = span. enter ( ) ;
133133 match cmd {
134134 Command :: Prepare { query, tx } => {
135- tx. send ( prepare ( & mut conn, & query) . map ( |prepared| {
135+ tx. send ( prepare ( & mut conn, query) . map ( |prepared| {
136136 update_cached_statements_size (
137137 & conn,
138138 & shared. cached_statements_size ,
@@ -142,7 +142,7 @@ impl ConnectionWorker {
142142 . ok ( ) ;
143143 }
144144 Command :: Describe { query, tx } => {
145- tx. send ( describe ( & mut conn, & query) ) . ok ( ) ;
145+ tx. send ( describe ( & mut conn, query) ) . ok ( ) ;
146146 }
147147 Command :: Execute {
148148 query,
@@ -151,7 +151,7 @@ impl ConnectionWorker {
151151 tx,
152152 limit
153153 } => {
154- let iter = match execute:: iter ( & mut conn, & query, arguments, persistent)
154+ let iter = match execute:: iter ( & mut conn, query, arguments, persistent)
155155 {
156156 Ok ( iter) => iter,
157157 Err ( e) => {
@@ -198,7 +198,7 @@ impl ConnectionWorker {
198198 let depth = conn. transaction_depth ;
199199 let res =
200200 conn. handle
201- . exec ( begin_ansi_transaction_sql ( depth) )
201+ . exec ( begin_ansi_transaction_sql ( depth) . as_str ( ) )
202202 . map ( |_| {
203203 conn. transaction_depth += 1 ;
204204 } ) ;
@@ -211,7 +211,7 @@ impl ConnectionWorker {
211211 // immediately otherwise it would remain started forever.
212212 if let Err ( error) = conn
213213 . handle
214- . exec ( rollback_ansi_transaction_sql ( depth + 1 ) )
214+ . exec ( rollback_ansi_transaction_sql ( depth + 1 ) . as_str ( ) )
215215 . map ( |_| {
216216 conn. transaction_depth -= 1 ;
217217 } )
@@ -229,7 +229,7 @@ impl ConnectionWorker {
229229
230230 let res = if depth > 0 {
231231 conn. handle
232- . exec ( commit_ansi_transaction_sql ( depth) )
232+ . exec ( commit_ansi_transaction_sql ( depth) . as_str ( ) )
233233 . map ( |_| {
234234 conn. transaction_depth -= 1 ;
235235 } )
@@ -255,7 +255,7 @@ impl ConnectionWorker {
255255
256256 let res = if depth > 0 {
257257 conn. handle
258- . exec ( rollback_ansi_transaction_sql ( depth) )
258+ . exec ( rollback_ansi_transaction_sql ( depth) . as_str ( ) )
259259 . map ( |_| {
260260 conn. transaction_depth -= 1 ;
261261 } )
@@ -308,25 +308,19 @@ impl ConnectionWorker {
308308 establish_rx. await . map_err ( |_| Error :: WorkerCrashed ) ?
309309 }
310310
311- pub ( crate ) async fn prepare ( & mut self , query : & str ) -> Result < SqliteStatement , Error > {
312- self . oneshot_cmd ( |tx| Command :: Prepare {
313- query : query. into ( ) ,
314- tx,
315- } )
316- . await ?
311+ pub ( crate ) async fn prepare ( & mut self , query : SqlStr ) -> Result < SqliteStatement , Error > {
312+ self . oneshot_cmd ( |tx| Command :: Prepare { query, tx } )
313+ . await ?
317314 }
318315
319- pub ( crate ) async fn describe ( & mut self , query : & str ) -> Result < Describe < Sqlite > , Error > {
320- self . oneshot_cmd ( |tx| Command :: Describe {
321- query : query. into ( ) ,
322- tx,
323- } )
324- . await ?
316+ pub ( crate ) async fn describe ( & mut self , query : SqlStr ) -> Result < Describe < Sqlite > , Error > {
317+ self . oneshot_cmd ( |tx| Command :: Describe { query, tx } )
318+ . await ?
325319 }
326320
327321 pub ( crate ) async fn execute (
328322 & mut self ,
329- query : & str ,
323+ query : SqlStr ,
330324 args : Option < SqliteArguments < ' _ > > ,
331325 chan_size : usize ,
332326 persistent : bool ,
@@ -337,7 +331,7 @@ impl ConnectionWorker {
337331 self . command_tx
338332 . send_async ( (
339333 Command :: Execute {
340- query : query . into ( ) ,
334+ query,
341335 arguments : args. map ( SqliteArguments :: into_static) ,
342336 persistent,
343337 tx,
@@ -465,9 +459,9 @@ impl ConnectionWorker {
465459 }
466460}
467461
468- fn prepare ( conn : & mut ConnectionState , query : & str ) -> Result < SqliteStatement , Error > {
462+ fn prepare ( conn : & mut ConnectionState , query : SqlStr ) -> Result < SqliteStatement , Error > {
469463 // prepare statement object (or checkout from cache)
470- let statement = conn. statements . get ( query, true ) ?;
464+ let statement = conn. statements . get ( query. as_str ( ) , true ) ?;
471465
472466 let mut parameters = 0 ;
473467 let mut columns = None ;
@@ -484,7 +478,7 @@ fn prepare(conn: &mut ConnectionState, query: &str) -> Result<SqliteStatement, E
484478 }
485479
486480 Ok ( SqliteStatement {
487- sql : AssertSqlSafe ( query) . into_sql_str ( ) ,
481+ sql : query,
488482 columns : columns. unwrap_or_default ( ) ,
489483 column_names : column_names. unwrap_or_default ( ) ,
490484 parameters,
0 commit comments