Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Aug 15, 2024
1 parent 8a6ecbf commit abb715c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
3 changes: 2 additions & 1 deletion diesel-wasm-sqlite/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"napi-derive": ["napi"],
"async-recursion": ["async_recursion"],
"ctor": ["ctor"],
"tokio": ["test"]
"tokio": ["test"],
"diesel": ["table"],
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions diesel-wasm-sqlite/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use std::sync::{Arc, Mutex};

use diesel::{connection::{ConnectionSealed, Instrumentation}, query_builder::{AsQuery, QueryFragment, QueryId}, QueryResult};
pub use diesel_async::{AnsiTransactionManager, AsyncConnection, SimpleAsyncConnection, TransactionManager, stmt_cache::StmtCache};
use row::SqliteRow;

use crate::{get_sqlite_unchecked, WasmSqlite, WasmSqliteError};

Expand All @@ -43,7 +42,6 @@ pub struct WasmSqliteConnection {
transaction_manager: AnsiTransactionManager,
// this exists for the sole purpose of implementing `WithMetadataLookup` trait
// and avoiding static mut which will be deprecated in 2024 edition
metadata_lookup: (),
instrumentation: Arc<Mutex<Option<Box<dyn Instrumentation>>>>,
}

Expand Down Expand Up @@ -286,7 +284,6 @@ impl WasmSqliteConnection {
statement_cache: StmtCache::new(),
raw_connection,
transaction_manager: AnsiTransactionManager::default(),
metadata_lookup: (),
instrumentation: Arc::new(Mutex::new(None)),
})
}
Expand Down
3 changes: 3 additions & 0 deletions diesel-wasm-sqlite/src/connection/raw.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(dead_code)]
// functions are needed, but missing functionality means they aren't used yet.

use crate::{
sqlite_types::{SqliteFlags, SqliteOpenFlags},
SqliteType, WasmSqlite, WasmSqliteError,
Expand Down
55 changes: 28 additions & 27 deletions diesel-wasm-sqlite/src/connection/sqlite_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,39 @@ impl<'row, 'stmt> SqliteValue<'row, 'stmt> {
Some(ret)
}
}
/*
pub(crate) fn parse_string<R>(&self, f: impl FnOnce(String) -> R) -> R {
let sqlite3 = crate::get_sqlite_unchecked();
let s = sqlite3.value_text(&self.value);
f(s)
}
pub(crate) fn parse_string<R>(&self, f: impl FnOnce(String) -> R) -> R {
let sqlite3 = crate::get_sqlite_unchecked();
let s = sqlite3.value_text(&self.value);
f(s)
}

// TODO: Wasm bindgen can't work with references yet
// not sure if this will effect perf
pub(crate) fn read_text(&self) -> String {
self.parse_string(|s| s)
}
// TODO: Wasm bindgen can't work with references yet
// not sure if this will effect perf
pub(crate) fn read_text(&self) -> String {
self.parse_string(|s| s)
}
pub(crate) fn read_blob(&self) -> Vec<u8> {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_blob(&self.value)
}
pub(crate) fn read_blob(&self) -> Vec<u8> {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_blob(&self.value)
}
pub(crate) fn read_integer(&self) -> i32 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_int(&self.value)
}
pub(crate) fn read_integer(&self) -> i32 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_int(&self.value)
}
pub(crate) fn read_long(&self) -> i64 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_int64(&self.value)
}
pub(crate) fn read_long(&self) -> i64 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_int64(&self.value)
}
pub(crate) fn read_double(&self) -> f64 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_double(&self.value)
}
pub(crate) fn read_double(&self) -> f64 {
let sqlite3 = crate::get_sqlite_unchecked();
sqlite3.value_double(&self.value)
}
*/

/// Get the type of the value as returned by sqlite
pub fn value_type(&self) -> Option<SqliteType> {
Expand Down
9 changes: 3 additions & 6 deletions diesel-wasm-sqlite/src/connection/stmt.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
#![allow(unsafe_code)] //TODO: can probably remove for wa-sqlite
use super::bind_collector::{
InternalSqliteBindValue, OwnedSqliteBindValue, SqliteBindCollector, SqliteBindCollectorData,
};
use super::bind_collector::{OwnedSqliteBindValue, SqliteBindCollectorData};
use super::raw::RawConnection;
use super::sqlite_value::OwnedSqliteValue;
use crate::ffi::SQLiteCompatibleType;
use crate::{
sqlite_types::{self, PrepareOptions, SqlitePrepareFlags},
SqliteType, WasmSqlite,
SqliteType,
};
use diesel::query_builder::bind_collector;
use diesel::{
connection::{
statement_cache::{MaybeCached, PrepareForCache},
Instrumentation,
},
query_builder::{QueryFragment, QueryId},
result::{Error, QueryResult},
};
use std::cell::OnceCell;
Expand Down Expand Up @@ -189,6 +185,7 @@ struct BoundStatement<'stmt> {
// generic type, we use NonNull to communicate
// that this is a shared buffer
// query: Option<Box<dyn QueryFragment<WasmSqlite>>>,
#[allow(unused)]
instrumentation: Arc<Mutex<dyn Instrumentation>>,
has_error: bool,
}
Expand Down

0 comments on commit abb715c

Please sign in to comment.