Skip to content

Commit

Permalink
diesel/src/mysql/connection/stmt/mod.rs: + StatementUse::insert_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
mcronce committed Sep 19, 2024
1 parent a907165 commit f107b98
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions diesel/src/mysql/connection/stmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ impl<'a> StatementUse<'a> {
.map_err(|e| Error::DeserializationError(Box::new(e)))
}

/// SAFETY: This should only be called for INSERT queries.
pub(in crate::mysql::connection) unsafe fn insert_id(&self) -> u64 {
let insert_id = ffi::mysql_stmt_insert_id(self.inner.stmt.as_ptr());
insert_id as u64
}

/// This function should be called after `execute` only
/// otherwise it's not guaranteed to return a valid result
pub(in crate::mysql::connection) unsafe fn result_size(&mut self) -> QueryResult<usize> {
Expand Down

0 comments on commit f107b98

Please sign in to comment.