Skip to content

Commit 7b88cbc

Browse files
authored
Improve column_count error handling and documentation (#541)
Closes #261
2 parents 6be725f + 1c721fe commit 7b88cbc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

crates/duckdb/src/column.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ impl Statement<'_> {
4949
/// If associated DB schema can be altered concurrently, you should make
5050
/// sure that current statement has already been stepped once before
5151
/// calling this method.
52+
///
53+
/// # Caveats
54+
/// Panics if the query has not been [`execute`](Statement::execute)d yet.
5255
#[inline]
5356
pub fn column_count(&self) -> usize {
5457
self.stmt.column_count()

crates/duckdb/src/raw_statement.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl RawStatement {
7171

7272
#[inline]
7373
pub fn result_unwrap(&self) -> ffi::duckdb_arrow {
74-
self.result.unwrap()
74+
self.result.expect("The statement was not executed yet")
7575
}
7676

7777
#[inline]
@@ -198,6 +198,8 @@ impl RawStatement {
198198
}
199199
}
200200

201+
// FIXME(mlafeldt): This currently panics if the query has not been executed yet.
202+
// The C API doesn't have a function to get the column count without executing the query first.
201203
#[inline]
202204
pub fn column_count(&self) -> usize {
203205
unsafe { ffi::duckdb_arrow_column_count(self.result_unwrap()) as usize }

0 commit comments

Comments
 (0)