File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
diesel/src/mysql/connection Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,34 @@ impl Connection for MysqlConnection {
211211 }
212212}
213213
214+ impl ConnectionWithReturningId for MysqlConnection {
215+ type ReturnedId = u64 ;
216+
217+ fn execute_returning_id < T > ( & mut self , source : & T ) -> QueryResult < Self :: ReturnedId >
218+ where
219+ T : QueryFragment < Self :: Backend > + QueryId ,
220+ {
221+ #[ allow( unsafe_code) ] // call to unsafe function
222+ update_transaction_manager_status (
223+ prepared_query (
224+ & source,
225+ & mut self . statement_cache ,
226+ & mut self . raw_connection ,
227+ & mut * self . instrumentation ,
228+ )
229+ . and_then ( |stmt| {
230+ // we have not called result yet, so calling `execute` is
231+ // fine
232+ let stmt_use = unsafe { stmt. execute ( ) } ?;
233+ Ok ( unsafe { stmt_use. insert_id ( ) } )
234+ } ) ,
235+ & mut self . transaction_state ,
236+ & mut self . instrumentation ,
237+ & crate :: debug_query ( source) ,
238+ )
239+ }
240+ }
241+
214242#[ inline( always) ]
215243fn update_transaction_manager_status < T > (
216244 query_result : QueryResult < T > ,
You can’t perform that action at this time.
0 commit comments