Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libsql/src/hrana/hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ impl crate::statement::Stmt for crate::hrana::Statement<HttpSender> {
Some(&named_param.name)
}

fn column_count(&self) -> usize {
self.cols.len()
}

fn columns(&self) -> Vec<crate::Column> {
//FIXME: there are several blockers here:
// 1. We cannot know the column types before sending a query, so this method will never return results right
Expand Down
4 changes: 4 additions & 0 deletions libsql/src/local/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ impl Stmt for LibsqlStmt {
self.0.parameter_name(idx)
}

fn column_count(&self) -> usize {
self.0.column_count()
}

fn columns(&self) -> Vec<Column> {
self.0.columns()
}
Expand Down
10 changes: 10 additions & 0 deletions libsql/src/replication/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,16 @@ impl Stmt for RemoteStatement {
}
}

fn column_count(&self) -> usize {
if let Some(stmt) = self.local_statement.as_ref() {
return stmt.column_count();
}
match self.metas.first() {
Some(meta) => meta.columns.len(),
None => 0,
}
}

fn columns(&self) -> Vec<Column> {
if let Some(stmt) = self.local_statement.as_ref() {
return stmt.columns();
Expand Down
7 changes: 7 additions & 0 deletions libsql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub(crate) trait Stmt {

fn parameter_name(&self, idx: i32) -> Option<&str>;

fn column_count(&self) -> usize;

fn columns(&self) -> Vec<Column>;
}

Expand Down Expand Up @@ -95,6 +97,11 @@ impl Statement {
self.inner.parameter_name(idx)
}

/// Fetch the number of columns for the prepared statement.
pub fn column_count(&self) -> usize {
self.inner.column_count()
}

/// Fetch the list of columns for the prepared statement.
pub fn columns(&self) -> Vec<Column> {
self.inner.columns()
Expand Down
4 changes: 4 additions & 0 deletions libsql/src/sync/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ impl Stmt for SyncedStatement {
self.inner.parameter_name(idx)
}

fn column_count(&self) -> usize {
self.inner.column_count()
}

fn columns(&self) -> Vec<Column> {
self.inner.columns()
}
Expand Down
Loading