mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 19:01:38 +08:00
Merge pull request #752 from Dushistov/omit-decltype
adding ability to work with sqlite compiled with -DSQLITE_OMIT_DECLTYPE
This commit is contained in:
commit
48a15857fb
@ -59,6 +59,7 @@ in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
|
|||||||
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
||||||
# Build bundled sqlite with -fsanitize=address
|
# Build bundled sqlite with -fsanitize=address
|
||||||
with-asan = ["libsqlite3-sys/with-asan"]
|
with-asan = ["libsqlite3-sys/with-asan"]
|
||||||
|
column_decltype = []
|
||||||
|
|
||||||
# Helper feature for enabling both `bundled` and most non-build-related optional
|
# Helper feature for enabling both `bundled` and most non-build-related optional
|
||||||
# features or dependencies. This is useful for running tests / clippy / etc. New
|
# features or dependencies. This is useful for running tests / clippy / etc. New
|
||||||
@ -71,6 +72,7 @@ bundled-full = [
|
|||||||
"bundled",
|
"bundled",
|
||||||
"chrono",
|
"chrono",
|
||||||
"collation",
|
"collation",
|
||||||
|
"column_decltype",
|
||||||
"csvtab",
|
"csvtab",
|
||||||
"extra_check",
|
"extra_check",
|
||||||
"functions",
|
"functions",
|
||||||
@ -134,7 +136,7 @@ name = "cache"
|
|||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = [ "backup", "blob", "chrono", "collation", "functions", "limits", "load_extension", "serde_json", "trace", "url", "vtab", "window", "modern_sqlite" ]
|
features = [ "backup", "blob", "chrono", "collation", "functions", "limits", "load_extension", "serde_json", "trace", "url", "vtab", "window", "modern_sqlite", "column_decltype" ]
|
||||||
all-features = false
|
all-features = false
|
||||||
no-default-features = true
|
no-default-features = true
|
||||||
default-target = "x86_64-unknown-linux-gnu"
|
default-target = "x86_64-unknown-linux-gnu"
|
||||||
|
@ -86,6 +86,7 @@ impl Statement<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice describing the columns of the result of the query.
|
/// Returns a slice describing the columns of the result of the query.
|
||||||
|
#[cfg(feature = "column_decltype")]
|
||||||
pub fn columns(&self) -> Vec<Column> {
|
pub fn columns(&self) -> Vec<Column> {
|
||||||
let n = self.column_count();
|
let n = self.column_count();
|
||||||
let mut cols = Vec::with_capacity(n as usize);
|
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.
|
/// Returns a slice describing the columns of the Rows.
|
||||||
|
#[cfg(feature = "column_decltype")]
|
||||||
pub fn columns(&self) -> Option<Vec<Column>> {
|
pub fn columns(&self) -> Option<Vec<Column>> {
|
||||||
self.stmt.map(Statement::columns)
|
self.stmt.map(Statement::columns)
|
||||||
}
|
}
|
||||||
@ -150,6 +152,7 @@ impl<'stmt> Row<'stmt> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice describing the columns of the Row.
|
/// Returns a slice describing the columns of the Row.
|
||||||
|
#[cfg(feature = "column_decltype")]
|
||||||
pub fn columns(&self) -> Vec<Column> {
|
pub fn columns(&self) -> Vec<Column> {
|
||||||
self.stmt.columns()
|
self.stmt.columns()
|
||||||
}
|
}
|
||||||
@ -157,11 +160,13 @@ impl<'stmt> Row<'stmt> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::Column;
|
|
||||||
use crate::Connection;
|
use crate::Connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "column_decltype")]
|
||||||
fn test_columns() {
|
fn test_columns() {
|
||||||
|
use super::Column;
|
||||||
|
|
||||||
let db = Connection::open_in_memory().unwrap();
|
let db = Connection::open_in_memory().unwrap();
|
||||||
let query = db.prepare("SELECT * FROM sqlite_master").unwrap();
|
let query = db.prepare("SELECT * FROM sqlite_master").unwrap();
|
||||||
let columns = query.columns();
|
let columns = query.columns();
|
||||||
|
@ -63,6 +63,7 @@ impl RawStatement {
|
|||||||
unsafe { ffi::sqlite3_column_type(self.ptr, idx as c_int) }
|
unsafe { ffi::sqlite3_column_type(self.ptr, idx as c_int) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "column_decltype")]
|
||||||
pub fn column_decltype(&self, idx: usize) -> Option<&CStr> {
|
pub fn column_decltype(&self, idx: usize) -> Option<&CStr> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let decltype = ffi::sqlite3_column_decltype(self.ptr, idx as c_int);
|
let decltype = ffi::sqlite3_column_decltype(self.ptr, idx as c_int);
|
||||||
|
Loading…
Reference in New Issue
Block a user