From 86facbbe4a62486f695aba56e0c44cd448bbec60 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 1 Jan 2024 23:56:04 +0100 Subject: [PATCH] sqlez --- crates/sqlez/src/migrations.rs | 8 ++++---- crates/sqlez/src/statement.rs | 4 ++-- crates/sqlez/src/thread_safe_connection.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/sqlez/src/migrations.rs b/crates/sqlez/src/migrations.rs index b8e589e268..c0d125d4df 100644 --- a/crates/sqlez/src/migrations.rs +++ b/crates/sqlez/src/migrations.rs @@ -20,8 +20,8 @@ impl Connection { self.sqlite3, sql_str.as_c_str().as_ptr(), None, - 0 as *mut _, - 0 as *mut _, + std::ptr::null_mut(), + std::ptr::null_mut(), ); } self.last_error() @@ -59,10 +59,10 @@ impl Connection { if completed_migration != migration { return Err(anyhow!(formatdoc! {" Migration changed for {} at step {} - + Stored migration: {} - + Proposed migration: {}", domain, index, completed_migration, migration})); } else { diff --git a/crates/sqlez/src/statement.rs b/crates/sqlez/src/statement.rs index de0ad626a5..122b6d0c58 100644 --- a/crates/sqlez/src/statement.rs +++ b/crates/sqlez/src/statement.rs @@ -232,13 +232,13 @@ impl<'a> Statement<'a> { .last_error() .with_context(|| format!("Failed to read text length at {index}"))?; - let slice = unsafe { slice::from_raw_parts(pointer as *const u8, len) }; + let slice = unsafe { slice::from_raw_parts(pointer, len) }; Ok(str::from_utf8(slice)?) } pub fn bind(&self, value: &T, index: i32) -> Result { debug_assert!(index > 0); - Ok(value.bind(self, index)?) + value.bind(self, index) } pub fn column(&mut self) -> Result { diff --git a/crates/sqlez/src/thread_safe_connection.rs b/crates/sqlez/src/thread_safe_connection.rs index 54241b6d72..98402df108 100644 --- a/crates/sqlez/src/thread_safe_connection.rs +++ b/crates/sqlez/src/thread_safe_connection.rs @@ -10,14 +10,14 @@ use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender} const MIGRATION_RETRIES: usize = 10; type QueuedWrite = Box; -type WriteQueueConstructor = - Box Box>; +type WriteQueue = Box; +type WriteQueueConstructor = Box WriteQueue>; lazy_static! { /// List of queues of tasks by database uri. This lets us serialize writes to the database /// and have a single worker thread per db file. This means many thread safe connections /// (possibly with different migrations) could all be communicating with the same background /// thread. - static ref QUEUES: RwLock, Box>> = + static ref QUEUES: RwLock, WriteQueue>> = Default::default(); }