mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-29 21:52:12 +08:00
commit
4c8b0ab6dd
@ -42,7 +42,7 @@ fn main() {
|
|||||||
&[&me.name, &me.time_created, &me.data]).unwrap();
|
&[&me.name, &me.time_created, &me.data]).unwrap();
|
||||||
|
|
||||||
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
||||||
let mut person_iter = stmt.query_map(&[], |row| {
|
let person_iter = stmt.query_map(&[], |row| {
|
||||||
Person {
|
Person {
|
||||||
id: row.get(0),
|
id: row.get(0),
|
||||||
name: row.get(1),
|
name: row.get(1),
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
//! # use std::path::Path;
|
//! # use std::path::Path;
|
||||||
//! # use std::time;
|
//! # use std::time;
|
||||||
//!
|
//!
|
||||||
//! fn backupDb<P: AsRef<Path>>(src: &Connection, dst: P, progress: fn(backup::Progress))
|
//! fn backup_db<P: AsRef<Path>>(src: &Connection, dst: P, progress: fn(backup::Progress))
|
||||||
//! -> Result<()> {
|
//! -> Result<()> {
|
||||||
//! let mut dst = try!(Connection::open(dst));
|
//! let mut dst = try!(Connection::open(dst));
|
||||||
//! let backup = try!(backup::Backup::new(src, &mut dst));
|
//! let backup = try!(backup::Backup::new(src, &mut dst));
|
||||||
|
@ -12,6 +12,7 @@ pub type SqliteError = Error;
|
|||||||
|
|
||||||
/// Enum listing possible errors from rusqlite.
|
/// Enum listing possible errors from rusqlite.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(enum_variant_names)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error from an underlying SQLite call.
|
/// An error from an underlying SQLite call.
|
||||||
SqliteFailure(ffi::Error, Option<String>),
|
SqliteFailure(ffi::Error, Option<String>),
|
||||||
@ -152,7 +153,6 @@ impl error::Error for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature="clippy", allow(match_same_arms))]
|
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SqliteFailure(ref err, _) => Some(err),
|
Error::SqliteFailure(ref err, _) => Some(err),
|
||||||
|
@ -274,10 +274,9 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # type c_double = f64;
|
|
||||||
/// fn scalar_function_example(db: Connection) -> Result<()> {
|
/// fn scalar_function_example(db: Connection) -> Result<()> {
|
||||||
/// try!(db.create_scalar_function("halve", 1, true, |ctx| {
|
/// try!(db.create_scalar_function("halve", 1, true, |ctx| {
|
||||||
/// let value = try!(ctx.get::<c_double>(0));
|
/// let value = try!(ctx.get::<f64>(0));
|
||||||
/// Ok(value / 2f64)
|
/// Ok(value / 2f64)
|
||||||
/// }));
|
/// }));
|
||||||
///
|
///
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
//! &[&me.name, &me.time_created, &me.data]).unwrap();
|
//! &[&me.name, &me.time_created, &me.data]).unwrap();
|
||||||
//!
|
//!
|
||||||
//! let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
//! let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
||||||
//! let mut person_iter = stmt.query_map(&[], |row| {
|
//! let person_iter = stmt.query_map(&[], |row| {
|
||||||
//! Person {
|
//! Person {
|
||||||
//! id: row.get(0),
|
//! id: row.get(0),
|
||||||
//! name: row.get(1),
|
//! name: row.get(1),
|
||||||
@ -50,6 +50,7 @@
|
|||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
#![allow(unknown_lints)]
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate libsqlite3_sys as ffi;
|
extern crate libsqlite3_sys as ffi;
|
||||||
@ -1019,6 +1020,7 @@ pub struct Rows<'stmt> {
|
|||||||
stmt: Option<&'stmt Statement<'stmt>>,
|
stmt: Option<&'stmt Statement<'stmt>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(should_implement_trait)]
|
||||||
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 { stmt: Some(stmt) }
|
Rows { stmt: Some(stmt) }
|
||||||
|
@ -94,7 +94,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result, Rows};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// fn query(conn: &Connection) -> Result<()> {
|
/// fn query(conn: &Connection) -> Result<()> {
|
||||||
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
|
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
|
||||||
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));
|
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));
|
||||||
|
@ -44,8 +44,8 @@ pub type SqliteTransaction<'conn> = Transaction<'conn>;
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
||||||
/// let tx = try!(conn.transaction());
|
/// let tx = try!(conn.transaction());
|
||||||
///
|
///
|
||||||
@ -73,8 +73,8 @@ pub struct Transaction<'conn> {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
||||||
/// let sp = try!(conn.savepoint());
|
/// let sp = try!(conn.savepoint());
|
||||||
///
|
///
|
||||||
@ -120,7 +120,7 @@ impl<'conn> Transaction<'conn> {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # fn perform_queries_part_1_succeeds(conn: &Connection) -> bool { true }
|
/// # fn perform_queries_part_1_succeeds(_conn: &Connection) -> bool { true }
|
||||||
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
||||||
/// let mut tx = try!(conn.transaction());
|
/// let mut tx = try!(conn.transaction());
|
||||||
///
|
///
|
||||||
@ -328,8 +328,8 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
||||||
/// let tx = try!(conn.transaction());
|
/// let tx = try!(conn.transaction());
|
||||||
///
|
///
|
||||||
@ -369,8 +369,8 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
|
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
|
||||||
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
|
||||||
/// let sp = try!(conn.savepoint());
|
/// let sp = try!(conn.savepoint());
|
||||||
///
|
///
|
||||||
@ -401,7 +401,6 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg_attr(feature="clippy", allow(similar_names))]
|
|
||||||
mod test {
|
mod test {
|
||||||
use Connection;
|
use Connection;
|
||||||
use super::DropBehavior;
|
use super::DropBehavior;
|
||||||
|
@ -108,7 +108,6 @@ impl fmt::Display for Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg_attr(feature="clippy", allow(similar_names))]
|
|
||||||
mod test {
|
mod test {
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
@ -209,7 +208,6 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(feature="clippy", allow(cyclomatic_complexity))]
|
|
||||||
fn test_mismatched_types() {
|
fn test_mismatched_types() {
|
||||||
fn is_invalid_column_type(err: Error) -> bool {
|
fn is_invalid_column_type(err: Error) -> bool {
|
||||||
match err {
|
match err {
|
||||||
|
Loading…
Reference in New Issue
Block a user