adding ability to work with sqlite compiled with -DSQLITE_OMIT_DECLTYPE

fix #751
This commit is contained in:
Evgeniy A. Dushistov
2020-06-01 00:02:18 +03:00
parent 8cdfaf36ae
commit d16748ac9f
3 changed files with 10 additions and 2 deletions

View File

@@ -86,6 +86,7 @@ impl Statement<'_> {
}
/// Returns a slice describing the columns of the result of the query.
#[cfg(feature = "column_decltype")]
pub fn columns(&self) -> Vec<Column> {
let n = self.column_count();
let mut cols = Vec::with_capacity(n as usize);
@@ -123,6 +124,7 @@ impl<'stmt> Rows<'stmt> {
}
/// Returns a slice describing the columns of the Rows.
#[cfg(feature = "column_decltype")]
pub fn columns(&self) -> Option<Vec<Column>> {
self.stmt.map(Statement::columns)
}
@@ -150,6 +152,7 @@ impl<'stmt> Row<'stmt> {
}
/// Returns a slice describing the columns of the Row.
#[cfg(feature = "column_decltype")]
pub fn columns(&self) -> Vec<Column> {
self.stmt.columns()
}
@@ -157,11 +160,13 @@ impl<'stmt> Row<'stmt> {
#[cfg(test)]
mod test {
use super::Column;
use crate::Connection;
#[test]
#[cfg(feature = "column_decltype")]
fn test_columns() {
use super::Column;
let db = Connection::open_in_memory().unwrap();
let query = db.prepare("SELECT * FROM sqlite_master").unwrap();
let columns = query.columns();

View File

@@ -63,6 +63,7 @@ impl RawStatement {
unsafe { ffi::sqlite3_column_type(self.ptr, idx as c_int) }
}
#[cfg(feature = "column_decltype")]
pub fn column_decltype(&self, idx: usize) -> Option<&CStr> {
unsafe {
let decltype = ffi::sqlite3_column_decltype(self.ptr, idx as c_int);