Merge pull request #563 from gwenn/open_flags

Check OpenFlags
This commit is contained in:
gwenn 2019-08-17 08:32:25 +02:00 committed by GitHub
commit 835b69fcb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 25 deletions

View File

@ -82,7 +82,7 @@ mod build_bundled {
// There may be other platforms that don't support `isnan`, they should be
// tested for here.
if cfg!(target_env = "msvc") {
use self::cc::windows_registry::{find_vs_version, VsVers};
use cc::windows_registry::{find_vs_version, VsVers};
let vs_has_nan = match find_vs_version() {
Ok(ver) => ver != VsVers::Vs12,
Err(_msg) => false,
@ -298,8 +298,8 @@ mod bindings {
mod bindings {
use bindgen;
use self::bindgen::callbacks::{IntKind, ParseCallbacks};
use super::HeaderLocation;
use bindgen::callbacks::{IntKind, ParseCallbacks};
use std::fs::OpenOptions;
use std::io::Write;

View File

@ -75,12 +75,11 @@ impl InnerConnection {
#[cfg(test)]
mod test {
use self::tempdir::TempDir;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::sync_channel;
use std::thread;
use std::time::Duration;
use tempdir;
use tempdir::TempDir;
use crate::{Connection, Error, ErrorCode, Result, TransactionBehavior, NO_PARAMS};

View File

@ -118,14 +118,14 @@ impl InnerConnection {
}
let callback: fn(&Connection, &str) -> Result<()> = mem::transmute(arg1);
if let Err(_) = catch_unwind(|| {
if catch_unwind(|| {
let conn = Connection::from_handle(arg2).unwrap();
let collation_name = {
let c_slice = CStr::from_ptr(arg3).to_bytes();
str::from_utf8_unchecked(c_slice)
};
callback(&conn, collation_name)
}) {
}).is_err() {
return; // FIXME How ?
}
}

View File

@ -682,9 +682,7 @@ where
#[cfg(test)]
mod test {
use regex;
use self::regex::Regex;
use regex::Regex;
use std::f64::EPSILON;
use std::os::raw::c_double;

View File

@ -850,13 +850,12 @@ unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
#[cfg(test)]
mod test {
use self::tempdir::TempDir;
pub use super::*;
use super::*;
use crate::ffi;
use fallible_iterator::FallibleIterator;
pub use std::error::Error as StdError;
pub use std::fmt;
use tempdir;
use std::error::Error as StdError;
use std::fmt;
use tempdir::TempDir;
// this function is never called, but is still type checked; in
// particular, calls with specific instantiations will require
@ -891,8 +890,8 @@ mod test {
)
.expect("create temp db");
let mut db1 = Connection::open(&path).unwrap();
let mut db2 = Connection::open(&path).unwrap();
let mut db1 = Connection::open_with_flags(&path, OpenFlags::SQLITE_OPEN_READ_WRITE).unwrap();
let mut db2 = Connection::open_with_flags(&path, OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap();
db1.busy_timeout(Duration::from_millis(0)).unwrap();
db2.busy_timeout(Duration::from_millis(0)).unwrap();

View File

@ -1,9 +1,8 @@
//! Convert most of the [Time Strings](http://sqlite.org/lang_datefunc.html) to chrono types.
use chrono;
use std::borrow::Cow;
use self::chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
use chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use crate::Result;
@ -129,10 +128,8 @@ impl FromSql for DateTime<Local> {
#[cfg(test)]
mod test {
use super::chrono::{
DateTime, Duration, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc,
};
use crate::{Connection, Result, NO_PARAMS};
use chrono::{DateTime, Duration, Local, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
fn checked_memory_handle() -> Connection {
let db = Connection::open_in_memory().unwrap();

View File

@ -1,7 +1,6 @@
//! `ToSql` and `FromSql` implementation for JSON `Value`.
use serde_json;
use self::serde_json::Value;
use serde_json::Value;
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use crate::Result;
@ -27,9 +26,9 @@ impl FromSql for Value {
#[cfg(test)]
mod test {
use super::serde_json;
use crate::types::ToSql;
use crate::{Connection, NO_PARAMS};
use serde_json;
fn checked_memory_handle() -> Connection {
let db = Connection::open_in_memory().unwrap();

View File

@ -36,8 +36,8 @@ impl FromSql for time::Timespec {
#[cfg(test)]
mod test {
use super::time;
use crate::{Connection, Result, NO_PARAMS};
use time;
fn checked_memory_handle() -> Connection {
let db = Connection::open_in_memory().unwrap();