mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Trivial tweaks
This commit is contained in:
parent
509257dfa8
commit
01b926c27e
@ -13,8 +13,8 @@ impl Connection {
|
|||||||
let c = self.db.borrow();
|
let c = self.db.borrow();
|
||||||
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, -1) }
|
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, -1) }
|
||||||
}
|
}
|
||||||
/// Changes the limit to `new_val`.
|
|
||||||
/// And returns the prior value of the limit.
|
/// Changes the limit to `new_val`, returning the prior value of the limit.
|
||||||
pub fn set_limit(&self, limit: Limit, new_val: i32) -> i32 {
|
pub fn set_limit(&self, limit: Limit, new_val: i32) -> i32 {
|
||||||
let c = self.db.borrow_mut();
|
let c = self.db.borrow_mut();
|
||||||
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, new_val) }
|
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, new_val) }
|
||||||
@ -23,7 +23,7 @@ impl Connection {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use ffi::{self, Limit};
|
use ffi::Limit;
|
||||||
use Connection;
|
use Connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -59,8 +59,8 @@ mod test {
|
|||||||
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));
|
||||||
|
|
||||||
let version = unsafe { ffi::sqlite3_libversion_number() };
|
// SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7.
|
||||||
if version >= 3008007 {
|
if ::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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user