mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Fix array module
This commit is contained in:
parent
e8dc412af1
commit
40ef85c2af
@ -170,7 +170,6 @@ mod test {
|
|||||||
use Connection;
|
use Connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // cargo test --lib --features "array" -- --ignored
|
|
||||||
fn test_array_module() {
|
fn test_array_module() {
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
array::load_module(&db).unwrap();
|
array::load_module(&db).unwrap();
|
||||||
|
@ -459,7 +459,7 @@ impl<'a> Values<'a> {
|
|||||||
// `sqlite3_value_type` returns `SQLITE_NULL` for pointer.
|
// `sqlite3_value_type` returns `SQLITE_NULL` for pointer.
|
||||||
// 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 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 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) };
|
||||||
@ -467,7 +467,10 @@ impl<'a> Values<'a> {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
Ok(Some(unsafe {
|
Ok(Some(unsafe {
|
||||||
array::Array::from_raw(ptr as *const Vec<Value>)
|
let rc = array::Array::from_raw(ptr as *const Vec<Value>);
|
||||||
|
let array = rc.clone();
|
||||||
|
array::Array::into_raw(rc); // don't consume it
|
||||||
|
array
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user