pub trait QueryResult {
// Required methods
fn rows_affected(&self) -> u64;
fn last_insert_id(&self) -> Option<u64>;
}Expand description
Extracts the affected row count and insert id from a backend query result.
sqlx’s Database::QueryResult associated type exposes these as
inherent methods on each concrete backend type. This trait provides
a single generic bound so the blanket Connection impl can call them
without knowing the concrete type.
Required Methods§
Sourcefn rows_affected(&self) -> u64
fn rows_affected(&self) -> u64
Returns the number of rows affected by the executed statement.
Sourcefn last_insert_id(&self) -> Option<u64>
fn last_insert_id(&self) -> Option<u64>
Returns the id the executed statement generated, if the backend knows it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl QueryResult for MySqlQueryResult
impl QueryResult for MySqlQueryResult
Source§fn last_insert_id(&self) -> Option<u64>
fn last_insert_id(&self) -> Option<u64>
The first AUTO_INCREMENT id; MySQL reports 0 when none was generated.
fn rows_affected(&self) -> u64
Source§impl QueryResult for PgQueryResult
impl QueryResult for PgQueryResult
Source§fn last_insert_id(&self) -> Option<u64>
fn last_insert_id(&self) -> Option<u64>
Always None: PostgreSQL returns generated keys through RETURNING.
fn rows_affected(&self) -> u64
Source§impl QueryResult for SqliteQueryResult
impl QueryResult for SqliteQueryResult
Source§fn last_insert_id(&self) -> Option<u64>
fn last_insert_id(&self) -> Option<u64>
Always None: SQLite keeps the last rowid per connection, not per statement.