mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
rustfmt
This commit is contained in:
parent
a4c3158b95
commit
71aa41c27a
@ -965,9 +965,7 @@ pub struct Rows<'stmt> {
|
|||||||
|
|
||||||
impl<'stmt> Rows<'stmt> {
|
impl<'stmt> Rows<'stmt> {
|
||||||
fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> {
|
fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> {
|
||||||
Rows {
|
Rows { stmt: Some(stmt) }
|
||||||
stmt: Some(stmt),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_expected_row<'a>(&'a mut self) -> Result<Row<'a, 'stmt>> {
|
fn get_expected_row<'a>(&'a mut self) -> Result<Row<'a, 'stmt>> {
|
||||||
|
@ -279,9 +279,10 @@ mod test {
|
|||||||
|
|
||||||
let mut stmt = db.prepare("SELECT id FROM test where name = :name").unwrap();
|
let mut stmt = db.prepare("SELECT id FROM test where name = :name").unwrap();
|
||||||
let mut rows = stmt.query_map_named(&[(":name", &"one")], |row| {
|
let mut rows = stmt.query_map_named(&[(":name", &"one")], |row| {
|
||||||
let id: i32 = row.get(0);
|
let id: i32 = row.get(0);
|
||||||
2 * id
|
2 * id
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let doubled_id: i32 = rows.next().unwrap().unwrap();
|
let doubled_id: i32 = rows.next().unwrap().unwrap();
|
||||||
assert_eq!(2, doubled_id);
|
assert_eq!(2, doubled_id);
|
||||||
@ -298,15 +299,17 @@ mod test {
|
|||||||
"#;
|
"#;
|
||||||
db.execute_batch(sql).unwrap();
|
db.execute_batch(sql).unwrap();
|
||||||
|
|
||||||
let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC").unwrap();
|
let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC")
|
||||||
|
.unwrap();
|
||||||
let mut rows = stmt.query_and_then_named(&[(":name", &"one")], |row| {
|
let mut rows = stmt.query_and_then_named(&[(":name", &"one")], |row| {
|
||||||
let id: i32 = row.get(0);
|
let id: i32 = row.get(0);
|
||||||
if id == 1 {
|
if id == 1 {
|
||||||
Ok(id)
|
Ok(id)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::SqliteSingleThreadedMode)
|
Err(Error::SqliteSingleThreadedMode)
|
||||||
}
|
}
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// first row should be Ok
|
// first row should be Ok
|
||||||
let doubled_id: i32 = rows.next().unwrap().unwrap();
|
let doubled_id: i32 = rows.next().unwrap().unwrap();
|
||||||
|
@ -209,7 +209,10 @@ impl<'conn> Drop for Transaction<'conn> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'conn> Savepoint<'conn> {
|
impl<'conn> Savepoint<'conn> {
|
||||||
fn with_depth_and_name<T: Into<String>>(conn: &Connection, depth: u32, name: T) -> Result<Savepoint> {
|
fn with_depth_and_name<T: Into<String>>(conn: &Connection,
|
||||||
|
depth: u32,
|
||||||
|
name: T)
|
||||||
|
-> Result<Savepoint> {
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
conn.execute_batch(&format!("SAVEPOINT {}", name)).map(|_| {
|
conn.execute_batch(&format!("SAVEPOINT {}", name)).map(|_| {
|
||||||
Savepoint {
|
Savepoint {
|
||||||
@ -349,7 +352,9 @@ impl Connection {
|
|||||||
/// # Failure
|
/// # Failure
|
||||||
///
|
///
|
||||||
/// Will return `Err` if the underlying SQLite call fails.
|
/// Will return `Err` if the underlying SQLite call fails.
|
||||||
pub fn transaction_with_behavior(&mut self, behavior: TransactionBehavior) -> Result<Transaction> {
|
pub fn transaction_with_behavior(&mut self,
|
||||||
|
behavior: TransactionBehavior)
|
||||||
|
-> Result<Transaction> {
|
||||||
Transaction::new(self, behavior)
|
Transaction::new(self, behavior)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user