Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orch8-api/src/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pub(crate) use bulk::{
__path_bulk_reschedule, __path_bulk_update_state, __path_list_dlq, bulk_reschedule,
bulk_update_state, list_dlq,
};
pub use checkpoints::{PruneCheckpointsRequest, SaveCheckpointRequest};
pub(crate) use checkpoints::{
__path_get_latest_checkpoint, __path_list_checkpoints, __path_prune_checkpoints,
__path_save_checkpoint, get_latest_checkpoint, list_checkpoints, prune_checkpoints,
save_checkpoint,
};
pub use checkpoints::{PruneCheckpointsRequest, SaveCheckpointRequest};
pub use inject::InjectBlocksRequest;
pub(crate) use inject::{__path_inject_blocks, inject_blocks};
pub(crate) use lifecycle::{
Expand Down
21 changes: 10 additions & 11 deletions orch8-storage/src/postgres/mobile_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,20 +571,19 @@ impl crate::MobileSyncStore for PostgresStorage {
if command_ids.is_empty() {
return Ok(0);
}
let placeholders: Vec<String> = command_ids
.iter()
.enumerate()
.map(|(i, _)| format!("${}", i + 2))
.collect();
let sql = format!(
"UPDATE mobile_commands SET acked_at = now() WHERE device_id = $1 AND id IN ({})",
placeholders.join(",")
let mut qb = sqlx::QueryBuilder::new(
"UPDATE mobile_commands SET acked_at = now() WHERE device_id = ",
);
let mut query = sqlx::query(&sql).bind(device_id);
qb.push_bind(device_id);
qb.push(" AND id IN (");
let mut separated = qb.separated(", ");
for id in command_ids {
query = query.bind(id);
separated.push_bind(id);
}
let result = query
separated.push_unseparated(")");

let result = qb
.build()
.execute(&self.pool)
.await
.map_err(|e| StorageError::Query(e.to_string()))?;
Expand Down
17 changes: 10 additions & 7 deletions orch8-storage/src/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2617,16 +2617,19 @@ impl crate::MobileSyncStore for SqliteStorage {
if command_ids.is_empty() {
return Ok(0);
}
let placeholders: Vec<&str> = command_ids.iter().map(|_| "?").collect();
let sql = format!(
"UPDATE mobile_commands SET acked_at = datetime('now') WHERE device_id = ? AND id IN ({})",
placeholders.join(",")
let mut qb = sqlx::QueryBuilder::new(
"UPDATE mobile_commands SET acked_at = datetime('now') WHERE device_id = ",
);
let mut query = sqlx::query(&sql).bind(device_id);
qb.push_bind(device_id);
qb.push(" AND id IN (");
let mut separated = qb.separated(", ");
for id in command_ids {
query = query.bind(id);
separated.push_bind(id);
}
let result = query
separated.push_unseparated(")");

let result = qb
.build()
.execute(&self.pool)
.await
.map_err(|e| StorageError::Query(e.to_string()))?;
Expand Down
Loading