mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-28 21:32:39 +00:00
sqlez
This commit is contained in:
parent
e2ec96e44a
commit
86facbbe4a
3 changed files with 9 additions and 9 deletions
|
@ -20,8 +20,8 @@ impl Connection {
|
||||||
self.sqlite3,
|
self.sqlite3,
|
||||||
sql_str.as_c_str().as_ptr(),
|
sql_str.as_c_str().as_ptr(),
|
||||||
None,
|
None,
|
||||||
0 as *mut _,
|
std::ptr::null_mut(),
|
||||||
0 as *mut _,
|
std::ptr::null_mut(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
self.last_error()
|
self.last_error()
|
||||||
|
@ -59,10 +59,10 @@ impl Connection {
|
||||||
if completed_migration != migration {
|
if completed_migration != migration {
|
||||||
return Err(anyhow!(formatdoc! {"
|
return Err(anyhow!(formatdoc! {"
|
||||||
Migration changed for {} at step {}
|
Migration changed for {} at step {}
|
||||||
|
|
||||||
Stored migration:
|
Stored migration:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Proposed migration:
|
Proposed migration:
|
||||||
{}", domain, index, completed_migration, migration}));
|
{}", domain, index, completed_migration, migration}));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -232,13 +232,13 @@ impl<'a> Statement<'a> {
|
||||||
.last_error()
|
.last_error()
|
||||||
.with_context(|| format!("Failed to read text length at {index}"))?;
|
.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)?)
|
Ok(str::from_utf8(slice)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind<T: Bind>(&self, value: &T, index: i32) -> Result<i32> {
|
pub fn bind<T: Bind>(&self, value: &T, index: i32) -> Result<i32> {
|
||||||
debug_assert!(index > 0);
|
debug_assert!(index > 0);
|
||||||
Ok(value.bind(self, index)?)
|
value.bind(self, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn column<T: Column>(&mut self) -> Result<T> {
|
pub fn column<T: Column>(&mut self) -> Result<T> {
|
||||||
|
|
|
@ -10,14 +10,14 @@ use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender}
|
||||||
const MIGRATION_RETRIES: usize = 10;
|
const MIGRATION_RETRIES: usize = 10;
|
||||||
|
|
||||||
type QueuedWrite = Box<dyn 'static + Send + FnOnce()>;
|
type QueuedWrite = Box<dyn 'static + Send + FnOnce()>;
|
||||||
type WriteQueueConstructor =
|
type WriteQueue = Box<dyn 'static + Send + Sync + Fn(QueuedWrite)>;
|
||||||
Box<dyn 'static + Send + FnMut() -> Box<dyn 'static + Send + Sync + Fn(QueuedWrite)>>;
|
type WriteQueueConstructor = Box<dyn 'static + Send + FnMut() -> WriteQueue>;
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// List of queues of tasks by database uri. This lets us serialize writes to the database
|
/// 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
|
/// 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
|
/// (possibly with different migrations) could all be communicating with the same background
|
||||||
/// thread.
|
/// thread.
|
||||||
static ref QUEUES: RwLock<HashMap<Arc<str>, Box<dyn 'static + Send + Sync + Fn(QueuedWrite)>>> =
|
static ref QUEUES: RwLock<HashMap<Arc<str>, WriteQueue>> =
|
||||||
Default::default();
|
Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue