chore: cleanup, fix all non-deprecation warnings

This commit is contained in:
Austin Bonander
2023-03-16 15:39:33 -07:00
committed by Austin Bonander
parent aa6c6d9752
commit d43257e18a
23 changed files with 28 additions and 139 deletions

View File

@@ -5,23 +5,17 @@ use crate::{
use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_util::{StreamExt, TryFutureExt, TryStreamExt};
use std::borrow::Cow;
use std::sync::Arc;
use sqlx_core::any::{
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
AnyStatement, AnyTypeInfo, AnyTypeInfoKind, AnyValue, AnyValueKind,
AnyStatement, AnyTypeInfo, AnyTypeInfoKind, AnyValueKind,
};
use crate::type_info::DataType;
use sqlx_core::any::driver::AnyDriver;
use sqlx_core::column::Column;
use sqlx_core::connection::{ConnectOptions, Connection};
use sqlx_core::database::Database;
use sqlx_core::describe::Describe;
use sqlx_core::executor::Executor;
use sqlx_core::ext::ustr::UStr;
use sqlx_core::row::Row;
use sqlx_core::transaction::TransactionManager;
sqlx_core::declare_driver_with_optional_migrate!(DRIVER = Sqlite);
@@ -109,7 +103,7 @@ impl AnyConnectionBackend for SqliteConnection {
let args = arguments.map(map_arguments);
Box::pin(async move {
let mut stream = self
let stream = self
.worker
.execute(query, args, self.row_channel_size, persistent)
.map_ok(flume::Receiver::into_stream)

View File

@@ -86,12 +86,6 @@ impl ConnectionHandle {
}
}
impl ConnectionHandleRaw {
pub(crate) fn as_ptr(&self) -> *mut sqlite3 {
self.0.as_ptr()
}
}
impl Drop for ConnectionHandle {
fn drop(&mut self) {
unsafe {

View File

@@ -14,7 +14,6 @@ use sqlx_core::transaction::{
};
use sqlx_core::Either;
use crate::connection::collation::create_collation;
use crate::connection::describe::describe;
use crate::connection::establish::EstablishParams;
use crate::connection::ConnectionState;
@@ -30,7 +29,7 @@ use crate::{Sqlite, SqliteArguments, SqliteQueryResult, SqliteRow, SqliteStateme
pub(crate) struct ConnectionWorker {
command_tx: flume::Sender<Command>,
/// The `sqlite3` pointer. NOTE: access is unsynchronized!
pub(crate) handle_raw: ConnectionHandleRaw,
pub(crate) _handle_raw: ConnectionHandleRaw,
/// Mutex for locking access to the database.
pub(crate) shared: Arc<WorkerSharedState>,
}
@@ -64,10 +63,6 @@ enum Command {
Rollback {
tx: Option<rendezvous_oneshot::Sender<Result<(), Error>>>,
},
CreateCollation {
create_collation:
Box<dyn FnOnce(&mut ConnectionState) -> Result<(), Error> + Send + Sync + 'static>,
},
UnlockDb,
ClearCache {
tx: oneshot::Sender<()>,
@@ -109,7 +104,7 @@ impl ConnectionWorker {
if establish_tx
.send(Ok(Self {
command_tx,
handle_raw: conn.handle.to_raw(),
_handle_raw: conn.handle.to_raw(),
shared: Arc::clone(&shared),
}))
.is_err()
@@ -241,11 +236,6 @@ impl ConnectionWorker {
}
}
}
Command::CreateCollation { create_collation } => {
if let Err(error) = (create_collation)(&mut conn) {
tracing::warn!(%error, "error applying collation in background worker");
}
}
Command::ClearCache { tx } => {
conn.statements.clear();
update_cached_statements_size(&conn, &shared.cached_statements_size);
@@ -364,23 +354,6 @@ impl ConnectionWorker {
rx.recv().await.map_err(|_| Error::WorkerCrashed)
}
pub fn create_collation(
&mut self,
name: &str,
compare: impl Fn(&str, &str) -> std::cmp::Ordering + Send + Sync + 'static,
) -> Result<(), Error> {
let name = name.to_string();
self.command_tx
.send(Command::CreateCollation {
create_collation: Box::new(move |conn| {
create_collation(&mut conn.handle, &name, compare)
}),
})
.map_err(|_| Error::WorkerCrashed)?;
Ok(())
}
pub(crate) async fn clear_cache(&mut self) -> Result<(), Error> {
self.oneshot_cmd(|tx| Command::ClearCache { tx }).await
}

View File

@@ -7,7 +7,6 @@ use crate::migrate::{AppliedMigration, Migration};
use crate::migrate::{Migrate, MigrateDatabase};
use crate::query::query;
use crate::query_as::query_as;
use crate::query_scalar::query_scalar;
use crate::{Sqlite, SqliteConnectOptions, SqliteConnection, SqliteJournalMode};
use futures_core::future::BoxFuture;
use std::str::FromStr;