mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:19:27 +08:00
commit
92020d54b7
@ -2,6 +2,7 @@
|
|||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||||
|
edition = "2018"
|
||||||
description = "Ergonomic wrapper for SQLite"
|
description = "Ergonomic wrapper for SQLite"
|
||||||
repository = "https://github.com/jgallagher/rusqlite"
|
repository = "https://github.com/jgallagher/rusqlite"
|
||||||
documentation = "http://docs.rs/rusqlite/"
|
documentation = "http://docs.rs/rusqlite/"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||||
|
edition = "2018"
|
||||||
repository = "https://github.com/jgallagher/rusqlite"
|
repository = "https://github.com/jgallagher/rusqlite"
|
||||||
description = "Native bindings to the libsqlite3 library"
|
description = "Native bindings to the libsqlite3 library"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -37,10 +37,10 @@ use std::os::raw::c_int;
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
|
|
||||||
use error::{error_from_handle, error_from_sqlite_code};
|
use crate::error::{error_from_handle, error_from_sqlite_code};
|
||||||
use {Connection, DatabaseName, Result};
|
use crate::{Connection, DatabaseName, Result};
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// Back up the `name` database to the given destination path.
|
/// Back up the `name` database to the given destination path.
|
||||||
@ -303,8 +303,8 @@ impl<'a, 'b> Drop for Backup<'a, 'b> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::Backup;
|
use super::Backup;
|
||||||
|
use crate::{Connection, DatabaseName, NO_PARAMS};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use {Connection, DatabaseName, NO_PARAMS};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_backup() {
|
fn test_backup() {
|
||||||
|
@ -64,7 +64,7 @@ use std::ptr;
|
|||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use super::types::{ToSql, ToSqlOutput};
|
use super::types::{ToSql, ToSqlOutput};
|
||||||
use {Connection, DatabaseName, Result};
|
use crate::{Connection, DatabaseName, Result};
|
||||||
|
|
||||||
/// Handle to an open BLOB.
|
/// Handle to an open BLOB.
|
||||||
pub struct Blob<'conn> {
|
pub struct Blob<'conn> {
|
||||||
@ -262,8 +262,8 @@ impl ToSql for ZeroBlob {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use crate::{Connection, DatabaseName, Result};
|
||||||
use std::io::{BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
|
use std::io::{BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
|
||||||
use {Connection, DatabaseName, Result};
|
|
||||||
|
|
||||||
fn db_with_test_blob() -> Result<(Connection, i64)> {
|
fn db_with_test_blob() -> Result<(Connection, i64)> {
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
|
@ -4,8 +4,8 @@ use std::os::raw::{c_int, c_void};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use {Connection, InnerConnection, Result};
|
use crate::{Connection, InnerConnection, Result};
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// Set a busy handler that sleeps for a specified amount of time when a
|
/// Set a busy handler that sleeps for a specified amount of time when a
|
||||||
@ -81,7 +81,7 @@ mod test {
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use {Connection, Error, ErrorCode, TransactionBehavior, NO_PARAMS};
|
use crate::{Connection, Error, ErrorCode, TransactionBehavior, NO_PARAMS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default_busy() {
|
fn test_default_busy() {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
//! Prepared statements cache for faster execution.
|
//! Prepared statements cache for faster execution.
|
||||||
|
|
||||||
|
use crate::raw_statement::RawStatement;
|
||||||
|
use crate::{Connection, Result, Statement};
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use raw_statement::RawStatement;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use {Connection, Result, Statement};
|
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// Prepare a SQL statement for execution, returning a previously prepared
|
/// Prepare a SQL statement for execution, returning a previously prepared
|
||||||
@ -152,7 +152,7 @@ impl StatementCache {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::StatementCache;
|
use super::StatementCache;
|
||||||
use {Connection, NO_PARAMS};
|
use crate::{Connection, NO_PARAMS};
|
||||||
|
|
||||||
impl StatementCache {
|
impl StatementCache {
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
|
@ -5,14 +5,14 @@ use std::os::raw::{c_char, c_int, c_void};
|
|||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use ffi::sqlite3_context;
|
use crate::ffi::sqlite3_context;
|
||||||
use ffi::sqlite3_value;
|
use crate::ffi::sqlite3_value;
|
||||||
|
|
||||||
use str_to_cstring;
|
use crate::str_to_cstring;
|
||||||
use types::{ToSqlOutput, ValueRef};
|
use crate::types::{ToSqlOutput, ValueRef};
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
use vtab::array::{free_array, ARRAY_TYPE};
|
use crate::vtab::array::{free_array, ARRAY_TYPE};
|
||||||
|
|
||||||
impl<'a> ValueRef<'a> {
|
impl<'a> ValueRef<'a> {
|
||||||
pub(crate) unsafe fn from_value(value: *mut sqlite3_value) -> ValueRef<'a> {
|
pub(crate) unsafe fn from_value(value: *mut sqlite3_value) -> ValueRef<'a> {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
|
use crate::types::Type;
|
||||||
|
use crate::{errmsg_to_string, ffi};
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str;
|
use std::str;
|
||||||
use types::Type;
|
|
||||||
use {errmsg_to_string, ffi};
|
|
||||||
|
|
||||||
/// Enum listing possible errors from rusqlite.
|
/// Enum listing possible errors from rusqlite.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(enum_variant_names)]
|
#[allow(clippy::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>),
|
||||||
|
@ -58,14 +58,14 @@ use std::os::raw::{c_int, c_void};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use ffi::sqlite3_context;
|
use crate::ffi::sqlite3_context;
|
||||||
use ffi::sqlite3_value;
|
use crate::ffi::sqlite3_value;
|
||||||
|
|
||||||
use context::set_result;
|
use crate::context::set_result;
|
||||||
use types::{FromSql, FromSqlError, ToSql, ValueRef};
|
use crate::types::{FromSql, FromSqlError, ToSql, ValueRef};
|
||||||
|
|
||||||
use {str_to_cstring, Connection, Error, InnerConnection, Result};
|
use crate::{str_to_cstring, Connection, Error, InnerConnection, Result};
|
||||||
|
|
||||||
unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
||||||
// Extended constraint error codes were added in SQLite 3.7.16. We don't have
|
// Extended constraint error codes were added in SQLite 3.7.16. We don't have
|
||||||
@ -198,14 +198,14 @@ where
|
|||||||
|
|
||||||
/// "step" function called once for each row in an aggregate group. May be
|
/// "step" function called once for each row in an aggregate group. May be
|
||||||
/// called 0 times if there are no rows.
|
/// called 0 times if there are no rows.
|
||||||
fn step(&self, &mut Context, &mut A) -> Result<()>;
|
fn step(&self, _: &mut Context, _: &mut A) -> Result<()>;
|
||||||
|
|
||||||
/// Computes and returns the final result. Will be called exactly once for
|
/// Computes and returns the final result. Will be called exactly once for
|
||||||
/// each invocation of the function. If `step()` was called at least
|
/// each invocation of the function. If `step()` was called at least
|
||||||
/// once, will be given `Some(A)` (the same `A` as was created by
|
/// once, will be given `Some(A)` (the same `A` as was created by
|
||||||
/// `init` and given to `step`); if `step()` was not called (because
|
/// `init` and given to `step`); if `step()` was not called (because
|
||||||
/// the function is running against 0 rows), will be given `None`.
|
/// the function is running against 0 rows), will be given `None`.
|
||||||
fn finalize(&self, Option<A>) -> Result<T>;
|
fn finalize(&self, _: Option<A>) -> Result<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
@ -490,8 +490,8 @@ mod test {
|
|||||||
use std::f64::EPSILON;
|
use std::f64::EPSILON;
|
||||||
use std::os::raw::c_double;
|
use std::os::raw::c_double;
|
||||||
|
|
||||||
use functions::{Aggregate, Context};
|
use crate::functions::{Aggregate, Context};
|
||||||
use {Connection, Error, Result, NO_PARAMS};
|
use crate::{Connection, Error, Result, NO_PARAMS};
|
||||||
|
|
||||||
fn half(ctx: &Context) -> Result<c_double> {
|
fn half(ctx: &Context) -> Result<c_double> {
|
||||||
assert!(ctx.len() == 1, "called with unexpected number of arguments");
|
assert!(ctx.len() == 1, "called with unexpected number of arguments");
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
|
|
||||||
use {Connection, InnerConnection};
|
use crate::{Connection, InnerConnection};
|
||||||
|
|
||||||
/// Authorizer Action Codes
|
/// Authorizer Action Codes
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -289,8 +289,8 @@ fn free_boxed_hook<F>(p: *mut c_void) {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::Action;
|
use super::Action;
|
||||||
|
use crate::Connection;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use Connection;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_commit_hook() {
|
fn test_commit_hook() {
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -88,27 +88,27 @@ use std::str;
|
|||||||
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
|
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
|
||||||
use std::sync::{Arc, Mutex, Once, ONCE_INIT};
|
use std::sync::{Arc, Mutex, Once, ONCE_INIT};
|
||||||
|
|
||||||
use cache::StatementCache;
|
use crate::cache::StatementCache;
|
||||||
use error::{error_from_handle, error_from_sqlite_code};
|
use crate::error::{error_from_handle, error_from_sqlite_code};
|
||||||
use raw_statement::RawStatement;
|
use crate::raw_statement::RawStatement;
|
||||||
use types::{ToSql, ValueRef};
|
use crate::types::{ToSql, ValueRef};
|
||||||
|
|
||||||
pub use statement::Statement;
|
pub use crate::statement::Statement;
|
||||||
|
|
||||||
pub use row::{AndThenRows, MappedRows, Row, RowIndex, Rows};
|
pub use crate::row::{AndThenRows, MappedRows, Row, RowIndex, Rows};
|
||||||
|
|
||||||
pub use transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior};
|
pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior};
|
||||||
|
|
||||||
pub use error::Error;
|
pub use crate::error::Error;
|
||||||
pub use ffi::ErrorCode;
|
pub use crate::ffi::ErrorCode;
|
||||||
|
|
||||||
pub use cache::CachedStatement;
|
pub use crate::cache::CachedStatement;
|
||||||
pub use version::*;
|
pub use crate::version::*;
|
||||||
|
|
||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
pub use hooks::*;
|
pub use crate::hooks::*;
|
||||||
#[cfg(feature = "load_extension")]
|
#[cfg(feature = "load_extension")]
|
||||||
pub use load_extension_guard::LoadExtensionGuard;
|
pub use crate::load_extension_guard::LoadExtensionGuard;
|
||||||
|
|
||||||
#[cfg(feature = "backup")]
|
#[cfg(feature = "backup")]
|
||||||
pub mod backup;
|
pub mod backup;
|
||||||
@ -1058,7 +1058,7 @@ mod test {
|
|||||||
extern crate tempdir;
|
extern crate tempdir;
|
||||||
use self::tempdir::TempDir;
|
use self::tempdir::TempDir;
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
pub use std::error::Error as StdError;
|
pub use std::error::Error as StdError;
|
||||||
pub use std::fmt;
|
pub use std::fmt;
|
||||||
|
|
||||||
@ -1548,9 +1548,7 @@ mod test {
|
|||||||
for (i, v) in vals.iter().enumerate() {
|
for (i, v) in vals.iter().enumerate() {
|
||||||
let i_to_insert = i as i64;
|
let i_to_insert = i as i64;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
insert_stmt
|
insert_stmt.execute(&[&i_to_insert as &ToSql, &v]).unwrap(),
|
||||||
.execute(&[&i_to_insert as &dyn ToSql, &v])
|
|
||||||
.unwrap(),
|
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
pub use ffi::Limit;
|
pub use crate::ffi::Limit;
|
||||||
|
|
||||||
use Connection;
|
use crate::Connection;
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// Returns the current value of a limit.
|
/// Returns the current value of a limit.
|
||||||
@ -23,8 +23,8 @@ impl Connection {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use ffi::Limit;
|
use crate::ffi::Limit;
|
||||||
use Connection;
|
use crate::Connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_limit() {
|
fn test_limit() {
|
||||||
@ -57,13 +57,13 @@ mod test {
|
|||||||
assert_eq!(99, db.limit(Limit::SQLITE_LIMIT_VARIABLE_NUMBER));
|
assert_eq!(99, db.limit(Limit::SQLITE_LIMIT_VARIABLE_NUMBER));
|
||||||
|
|
||||||
// SQLITE_LIMIT_TRIGGER_DEPTH was added in SQLite 3.6.18.
|
// SQLITE_LIMIT_TRIGGER_DEPTH was added in SQLite 3.6.18.
|
||||||
if ::version_number() >= 3006018 {
|
if crate::version_number() >= 3006018 {
|
||||||
db.set_limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH, 32);
|
db.set_limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH, 32);
|
||||||
assert_eq!(32, db.limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH));
|
assert_eq!(32, db.limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7.
|
// SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7.
|
||||||
if ::version_number() >= 3008007 {
|
if crate::version_number() >= 3008007 {
|
||||||
db.set_limit(Limit::SQLITE_LIMIT_WORKER_THREADS, 2);
|
db.set_limit(Limit::SQLITE_LIMIT_WORKER_THREADS, 2);
|
||||||
assert_eq!(2, db.limit(Limit::SQLITE_LIMIT_WORKER_THREADS));
|
assert_eq!(2, db.limit(Limit::SQLITE_LIMIT_WORKER_THREADS));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use {Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// RAII guard temporarily enabling SQLite extensions to be loaded.
|
/// RAII guard temporarily enabling SQLite extensions to be loaded.
|
||||||
///
|
///
|
||||||
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||||||
use std::{convert, result};
|
use std::{convert, result};
|
||||||
|
|
||||||
use super::{Error, Result, Statement};
|
use super::{Error, Result, Statement};
|
||||||
use types::{FromSql, FromSqlError, ValueRef};
|
use crate::types::{FromSql, FromSqlError, ValueRef};
|
||||||
|
|
||||||
/// An handle for the resulting rows of a query.
|
/// An handle for the resulting rows of a query.
|
||||||
pub struct Rows<'stmt> {
|
pub struct Rows<'stmt> {
|
||||||
@ -27,7 +27,7 @@ impl<'stmt> Rows<'stmt> {
|
|||||||
/// This is a "streaming iterator". For a more natural interface,
|
/// This is a "streaming iterator". For a more natural interface,
|
||||||
/// consider using `query_map` or `query_and_then` instead, which
|
/// consider using `query_map` or `query_and_then` instead, which
|
||||||
/// return types that implement `Iterator`.
|
/// return types that implement `Iterator`.
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))] // cannot implement Iterator
|
#[allow(clippy::should_implement_trait)] // cannot implement Iterator
|
||||||
pub fn next<'a>(&'a mut self) -> Option<Result<Row<'a, 'stmt>>> {
|
pub fn next<'a>(&'a mut self) -> Option<Result<Row<'a, 'stmt>>> {
|
||||||
self.stmt.and_then(|stmt| match stmt.step() {
|
self.stmt.and_then(|stmt| match stmt.step() {
|
||||||
Ok(true) => Some(Ok(Row {
|
Ok(true) => Some(Ok(Row {
|
||||||
|
@ -11,9 +11,9 @@ use super::str_to_cstring;
|
|||||||
use super::{
|
use super::{
|
||||||
AndThenRows, Connection, Error, MappedRows, RawStatement, Result, Row, Rows, ValueRef,
|
AndThenRows, Connection, Error, MappedRows, RawStatement, Result, Row, Rows, ValueRef,
|
||||||
};
|
};
|
||||||
use types::{ToSql, ToSqlOutput};
|
use crate::types::{ToSql, ToSqlOutput};
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
use vtab::array::{free_array, ARRAY_TYPE};
|
use crate::vtab::array::{free_array, ARRAY_TYPE};
|
||||||
|
|
||||||
/// A prepared statement.
|
/// A prepared statement.
|
||||||
pub struct Statement<'conn> {
|
pub struct Statement<'conn> {
|
||||||
@ -668,7 +668,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use {Connection, Error, Result, NO_PARAMS};
|
use crate::{Connection, Error, Result, NO_PARAMS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_execute_named() {
|
fn test_execute_named() {
|
||||||
|
@ -7,8 +7,8 @@ use std::ptr;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use error::error_from_sqlite_code;
|
use crate::error::error_from_sqlite_code;
|
||||||
use {Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// Set up the process-wide SQLite error logging callback.
|
/// Set up the process-wide SQLite error logging callback.
|
||||||
/// This function is marked unsafe for two reasons:
|
/// This function is marked unsafe for two reasons:
|
||||||
@ -124,7 +124,7 @@ mod test {
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use Connection;
|
use crate::Connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trace() {
|
fn test_trace() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::{Connection, Result};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use {Connection, Result};
|
|
||||||
|
|
||||||
/// Options for transaction behavior. See [BEGIN
|
/// Options for transaction behavior. See [BEGIN
|
||||||
/// TRANSACTION](http://www.sqlite.org/lang_transaction.html) for details.
|
/// TRANSACTION](http://www.sqlite.org/lang_transaction.html) for details.
|
||||||
@ -410,7 +410,7 @@ impl Connection {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::DropBehavior;
|
use super::DropBehavior;
|
||||||
use {Connection, NO_PARAMS};
|
use crate::{Connection, NO_PARAMS};
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
@ -5,8 +5,8 @@ use std::borrow::Cow;
|
|||||||
|
|
||||||
use self::chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
|
use self::chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
|
||||||
|
|
||||||
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||||
use Result;
|
use crate::Result;
|
||||||
|
|
||||||
/// ISO 8601 calendar date without timezone => "YYYY-MM-DD"
|
/// ISO 8601 calendar date without timezone => "YYYY-MM-DD"
|
||||||
impl ToSql for NaiveDate {
|
impl ToSql for NaiveDate {
|
||||||
@ -132,7 +132,7 @@ mod test {
|
|||||||
use super::chrono::{
|
use super::chrono::{
|
||||||
DateTime, Duration, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc,
|
DateTime, Duration, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc,
|
||||||
};
|
};
|
||||||
use {Connection, Result, NO_PARAMS};
|
use crate::{Connection, Result, NO_PARAMS};
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
@ -47,7 +47,7 @@ impl Error for FromSqlError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "clippy", allow(match_same_arms))]
|
#[allow(clippy::match_same_arms)]
|
||||||
fn cause(&self) -> Option<&Error> {
|
fn cause(&self) -> Option<&Error> {
|
||||||
match *self {
|
match *self {
|
||||||
FromSqlError::Other(ref err) => err.cause(),
|
FromSqlError::Other(ref err) => err.cause(),
|
||||||
@ -181,7 +181,7 @@ impl FromSql for Value {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::FromSql;
|
use super::FromSql;
|
||||||
use {Connection, Error};
|
use crate::{Connection, Error};
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
Connection::open_in_memory().unwrap()
|
Connection::open_in_memory().unwrap()
|
||||||
|
@ -114,9 +114,9 @@ mod test {
|
|||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use super::Value;
|
use super::Value;
|
||||||
|
use crate::{Connection, Error, NO_PARAMS};
|
||||||
use std::f64::EPSILON;
|
use std::f64::EPSILON;
|
||||||
use std::os::raw::{c_double, c_int};
|
use std::os::raw::{c_double, c_int};
|
||||||
use {Connection, Error, NO_PARAMS};
|
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
@ -3,8 +3,8 @@ extern crate serde_json;
|
|||||||
|
|
||||||
use self::serde_json::Value;
|
use self::serde_json::Value;
|
||||||
|
|
||||||
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||||
use Result;
|
use crate::Result;
|
||||||
|
|
||||||
/// Serialize JSON `Value` to text.
|
/// Serialize JSON `Value` to text.
|
||||||
impl ToSql for Value {
|
impl ToSql for Value {
|
||||||
@ -28,8 +28,8 @@ impl FromSql for Value {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::serde_json;
|
use super::serde_json;
|
||||||
use types::ToSql;
|
use crate::types::ToSql;
|
||||||
use {Connection, NO_PARAMS};
|
use crate::{Connection, NO_PARAMS};
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||||
use Result;
|
use crate::Result;
|
||||||
|
|
||||||
const CURRENT_TIMESTAMP_FMT: &str = "%Y-%m-%d %H:%M:%S";
|
const CURRENT_TIMESTAMP_FMT: &str = "%Y-%m-%d %H:%M:%S";
|
||||||
const SQLITE_DATETIME_FMT: &str = "%Y-%m-%dT%H:%M:%S.%fZ";
|
const SQLITE_DATETIME_FMT: &str = "%Y-%m-%dT%H:%M:%S.%fZ";
|
||||||
@ -37,7 +37,7 @@ impl FromSql for time::Timespec {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::time;
|
use super::time;
|
||||||
use {Connection, Result, NO_PARAMS};
|
use crate::{Connection, Result, NO_PARAMS};
|
||||||
|
|
||||||
fn checked_memory_handle() -> Connection {
|
fn checked_memory_handle() -> Connection {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use super::{Null, Value, ValueRef};
|
use super::{Null, Value, ValueRef};
|
||||||
use std::borrow::Cow;
|
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
use vtab::array::Array;
|
use crate::vtab::array::Array;
|
||||||
use Result;
|
use crate::Result;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// `ToSqlOutput` represents the possible output types for implementors of the
|
/// `ToSqlOutput` represents the possible output types for implementors of the
|
||||||
/// `ToSql` trait.
|
/// `ToSql` trait.
|
||||||
@ -207,8 +207,8 @@ mod test {
|
|||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_i128() {
|
fn test_i128() {
|
||||||
|
use crate::{Connection, NO_PARAMS};
|
||||||
use std::i128;
|
use std::i128;
|
||||||
use {Connection, NO_PARAMS};
|
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
db.execute_batch("CREATE TABLE foo (i128 BLOB, desc TEXT)")
|
db.execute_batch("CREATE TABLE foo (i128 BLOB, desc TEXT)")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::{Type, Value};
|
use super::{Type, Value};
|
||||||
use types::{FromSqlError, FromSqlResult};
|
use crate::types::{FromSqlError, FromSqlResult};
|
||||||
|
|
||||||
/// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the
|
/// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the
|
||||||
/// memory backing this value is owned by SQLite.
|
/// memory backing this value is owned by SQLite.
|
||||||
|
@ -6,7 +6,7 @@ use std::os::raw::c_void;
|
|||||||
#[cfg(feature = "unlock_notify")]
|
#[cfg(feature = "unlock_notify")]
|
||||||
use std::sync::{Condvar, Mutex};
|
use std::sync::{Condvar, Mutex};
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
|
|
||||||
#[cfg(feature = "unlock_notify")]
|
#[cfg(feature = "unlock_notify")]
|
||||||
struct UnlockNotification {
|
struct UnlockNotification {
|
||||||
@ -99,10 +99,10 @@ pub fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int {
|
|||||||
#[cfg(feature = "unlock_notify")]
|
#[cfg(feature = "unlock_notify")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use crate::{Connection, OpenFlags, Result, Transaction, TransactionBehavior, NO_PARAMS};
|
||||||
use std::sync::mpsc::sync_channel;
|
use std::sync::mpsc::sync_channel;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time;
|
use std::time;
|
||||||
use {Connection, OpenFlags, Result, Transaction, TransactionBehavior, NO_PARAMS};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unlock_notify() {
|
fn test_unlock_notify() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use ffi;
|
use crate::ffi;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
/// Returns the SQLite version as an integer; e.g., `3016002` for version
|
/// Returns the SQLite version as an integer; e.g., `3016002` for version
|
||||||
|
@ -5,13 +5,13 @@ use std::default::Default;
|
|||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use types::{ToSql, ToSqlOutput, Value};
|
use crate::types::{ToSql, ToSqlOutput, Value};
|
||||||
use vtab::{
|
use crate::vtab::{
|
||||||
eponymous_only_module, Context, IndexConstraintOp, IndexInfo, Module, VTab, VTabConnection,
|
eponymous_only_module, Context, IndexConstraintOp, IndexInfo, Module, VTab, VTabConnection,
|
||||||
VTabCursor, Values,
|
VTabCursor, Values,
|
||||||
};
|
};
|
||||||
use {Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
// http://sqlite.org/bindptr.html
|
// http://sqlite.org/bindptr.html
|
||||||
|
|
||||||
@ -169,10 +169,10 @@ impl VTabCursor for ArrayTabCursor {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use crate::types::Value;
|
||||||
|
use crate::vtab::array;
|
||||||
|
use crate::Connection;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use types::Value;
|
|
||||||
use vtab::array;
|
|
||||||
use Connection;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_array_module() {
|
fn test_array_module() {
|
||||||
|
@ -8,13 +8,13 @@ use std::path::Path;
|
|||||||
use std::result;
|
use std::result;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use types::Null;
|
use crate::types::Null;
|
||||||
use vtab::{
|
use crate::vtab::{
|
||||||
dequote, escape_double_quote, parse_boolean, read_only_module, Context, CreateVTab, IndexInfo,
|
dequote, escape_double_quote, parse_boolean, read_only_module, Context, CreateVTab, IndexInfo,
|
||||||
Module, VTab, VTabConnection, VTabCursor, Values,
|
Module, VTab, VTabConnection, VTabCursor, Values,
|
||||||
};
|
};
|
||||||
use {Connection, Error, Result};
|
use crate::{Connection, Error, Result};
|
||||||
|
|
||||||
/// Register the "csv" module.
|
/// Register the "csv" module.
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -340,8 +340,8 @@ impl From<csv::Error> for Error {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use vtab::csvtab;
|
use crate::vtab::csvtab;
|
||||||
use {Connection, Result, NO_PARAMS};
|
use crate::{Connection, Result, NO_PARAMS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_csv_module() {
|
fn test_csv_module() {
|
||||||
|
@ -17,12 +17,12 @@ use std::os::raw::{c_char, c_int, c_void};
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use context::set_result;
|
use crate::context::set_result;
|
||||||
use error::error_from_sqlite_code;
|
use crate::error::error_from_sqlite_code;
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
pub use ffi::{sqlite3_vtab, sqlite3_vtab_cursor};
|
pub use crate::ffi::{sqlite3_vtab, sqlite3_vtab_cursor};
|
||||||
use types::{FromSql, FromSqlError, ToSql, ValueRef};
|
use crate::types::{FromSql, FromSqlError, ToSql, ValueRef};
|
||||||
use {str_to_cstring, Connection, Error, InnerConnection, Result};
|
use crate::{str_to_cstring, Connection, Error, InnerConnection, Result};
|
||||||
|
|
||||||
// let conn: Connection = ...;
|
// let conn: Connection = ...;
|
||||||
// let mod: Module = ...; // VTab builder
|
// let mod: Module = ...; // VTab builder
|
||||||
@ -476,7 +476,7 @@ impl<'a> Values<'a> {
|
|||||||
// So it seems not possible to enhance `ValueRef::from_value`.
|
// So it seems not possible to enhance `ValueRef::from_value`.
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
pub(crate) fn get_array(&self, idx: usize) -> Result<Option<array::Array>> {
|
pub(crate) fn get_array(&self, idx: usize) -> Result<Option<array::Array>> {
|
||||||
use types::Value;
|
use crate::types::Value;
|
||||||
let arg = self.args[idx];
|
let arg = self.args[idx];
|
||||||
let ptr = unsafe { ffi::sqlite3_value_pointer(arg, array::ARRAY_TYPE) };
|
let ptr = unsafe { ffi::sqlite3_value_pointer(arg, array::ARRAY_TYPE) };
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use types::Type;
|
use crate::types::Type;
|
||||||
use vtab::{
|
use crate::vtab::{
|
||||||
eponymous_only_module, Context, IndexConstraintOp, IndexInfo, Module, VTab, VTabConnection,
|
eponymous_only_module, Context, IndexConstraintOp, IndexInfo, Module, VTab, VTabConnection,
|
||||||
VTabCursor, Values,
|
VTabCursor, Values,
|
||||||
};
|
};
|
||||||
use {Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// Register the "generate_series" module.
|
/// Register the "generate_series" module.
|
||||||
pub fn load_module(conn: &Connection) -> Result<()> {
|
pub fn load_module(conn: &Connection) -> Result<()> {
|
||||||
@ -263,9 +263,9 @@ impl VTabCursor for SeriesTabCursor {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use ffi;
|
use crate::ffi;
|
||||||
use vtab::series;
|
use crate::vtab::series;
|
||||||
use {Connection, NO_PARAMS};
|
use crate::{Connection, NO_PARAMS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_series_module() {
|
fn test_series_module() {
|
||||||
|
Loading…
Reference in New Issue
Block a user