Skip to content

Commit

Permalink
Add impl AdbcDatabase for DriverDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreyc committed Jan 30, 2024
1 parent 86519f2 commit 248af16
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion rust/src/driver_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use crate::{
DatabaseSchemaEntry, DatabaseTableEntry, ForeignKeyUsageRef, TableConstraintRef,
TableConstraintTypeRef,
},
AdbcConnection, AdbcStatement, PartitionedStatementResult, StatementResult,
AdbcConnection, AdbcDatabase, AdbcStatement, PartitionedStatementResult, StatementResult,
};

use self::util::{NullableCString, RowReference, StructArraySlice};
Expand Down Expand Up @@ -455,6 +455,28 @@ impl DriverDatabase {
}
}

impl AdbcDatabase for DriverDatabase {
type ConnectionType = DriverConnection;

fn set_option(&self, key: impl AsRef<str>, value: impl AsRef<str>) -> Result<()> {
self.set_option(key, value)
}

fn connect<K, V>(
&self,
options: impl IntoIterator<Item = (K, V)>,
) -> Result<Self::ConnectionType>
where
K: AsRef<str>,
V: AsRef<str>,
{
options
.into_iter()
.try_for_each(|(k, v)| self.set_option(k, v))?;
self.new_connection()?.init()
}
}

// Safety: the only thing in the builder that isn't Send + Sync is the
// FFI_AdbcDatabase within the AdbcDriverInner. The builder ensures it doesn't
// have multiple references to that before this struct is created. And within
Expand Down

0 comments on commit 248af16

Please sign in to comment.