Get the last id after `AUTOINCREMENT` is done on the primary key # Panics Postgres does not support retrieving last insert id this way except through `RETURNING` clause
(&self)
| 36 | /// |
| 37 | /// Postgres does not support retrieving last insert id this way except through `RETURNING` clause |
| 38 | pub fn last_insert_id(&self) -> u64 { |
| 39 | match &self.result { |
| 40 | #[cfg(feature = "sqlx-mysql")] |
| 41 | ExecResultHolder::SqlxMySql(result) => result.last_insert_id(), |
| 42 | #[cfg(feature = "sqlx-postgres")] |
| 43 | ExecResultHolder::SqlxPostgres(_) => { |
| 44 | panic!("Should not retrieve last_insert_id this way") |
| 45 | } |
| 46 | #[cfg(feature = "sqlx-sqlite")] |
| 47 | ExecResultHolder::SqlxSqlite(result) => { |
| 48 | let last_insert_rowid = result.last_insert_rowid(); |
| 49 | if last_insert_rowid < 0 { |
| 50 | unreachable!("negative last_insert_rowid") |
| 51 | } else { |
| 52 | last_insert_rowid as u64 |
| 53 | } |
| 54 | } |
| 55 | #[cfg(feature = "mock")] |
| 56 | ExecResultHolder::Mock(result) => result.last_insert_id, |
| 57 | #[cfg(feature = "proxy")] |
| 58 | ExecResultHolder::Proxy(result) => result.last_insert_id, |
| 59 | #[allow(unreachable_patterns)] |
| 60 | _ => unreachable!(), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// Get the number of rows affected by the operation |
| 65 | pub fn rows_affected(&self) -> u64 { |
no outgoing calls
no test coverage detected