mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-20 21:09:31 +08:00
adding ability to work with sqlite compiled with -DSQLITE_OMIT_DECLTYPE
fix #751
This commit is contained in:
@@ -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();
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user