Skip to content

Commit c151c42

Browse files
committed
chore: bump up deps
1 parent 1557172 commit c151c42

11 files changed

Lines changed: 1140 additions & 1258 deletions

File tree

Cargo.lock

Lines changed: 383 additions & 422 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ redundant_pub_crate = "allow"
3434

3535
[workspace.dependencies]
3636
async-trait = "0.1.89"
37-
chrono = { version = "0.4.44", features = ["serde"] }
37+
chrono = { version = "0.4.45", features = ["serde"] }
3838
cqrs-es = "0.4.12"
3939
serde = { version = "1.0.228", features = ["derive"] }
40-
serde_json = "1.0.149"
40+
serde_json = "1.0.150"
4141
sqlite-es = { path = "crates/sqlite-es" }
42-
sqlx = { version = "0.8.6", features = [
42+
sqlx = { version = "0.9.0", features = [
4343
"sqlite",
4444
"chrono",
45-
"runtime-tokio-rustls",
45+
"runtime-tokio",
46+
"tls-rustls",
4647
] }
4748
thiserror = "2.0.18"
4849
tokio = { version = "1.52.3", features = ["full"] }

crates/event-sorcery/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ use cqrs_es::EventStore;
9494
use cqrs_es::persist::PersistedEventStore;
9595
use serde::Serialize;
9696
use serde::de::DeserializeOwned;
97+
use sqlx::AssertSqlSafe;
9798
use sqlx::SqlitePool;
9899
use std::fmt::{Debug, Display};
99100
use std::str::FromStr;
@@ -506,7 +507,7 @@ pub async fn vacuum(pool: &SqlitePool) -> Result<(), sqlx::Error> {
506507
///
507508
/// Returns database errors from SQLite `PRAGMA incremental_vacuum`.
508509
pub async fn incremental_vacuum(pool: &SqlitePool, pages: u32) -> Result<(), sqlx::Error> {
509-
sqlx::query(&format!("PRAGMA incremental_vacuum({pages})"))
510+
sqlx::query(AssertSqlSafe(format!("PRAGMA incremental_vacuum({pages})")))
510511
.execute(pool)
511512
.await?;
512513
Ok(())

crates/event-sorcery/src/projection.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use async_trait::async_trait;
99
use cqrs_es::Aggregate;
1010
use cqrs_es::persist::{PersistenceError, ViewContext, ViewRepository};
1111
use sqlite_es::SqliteViewRepository;
12+
use sqlx::AssertSqlSafe;
1213
use sqlx::SqlitePool;
1314
use sqlx::sqlite::Sqlite;
1415
use std::fmt::Debug;
@@ -162,7 +163,8 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
162163
ORDER BY view_id ASC"
163164
);
164165

165-
let rows: Vec<(String, String)> = sqlx::query_as(&query).fetch_all(pool).await?;
166+
let rows: Vec<(String, String)> =
167+
sqlx::query_as(AssertSqlSafe(query)).fetch_all(pool).await?;
166168

167169
Ok(Self::parse_rows(rows))
168170
}
@@ -202,8 +204,10 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
202204
ORDER BY view_id ASC"
203205
);
204206

205-
let rows: Vec<(String, String)> =
206-
sqlx::query_as(&query).bind(value).fetch_all(pool).await?;
207+
let rows: Vec<(String, String)> = sqlx::query_as(AssertSqlSafe(query))
208+
.bind(value)
209+
.fetch_all(pool)
210+
.await?;
207211

208212
Ok(Self::parse_rows(rows))
209213
}
@@ -224,8 +228,9 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
224228
// Drive from events table (LEFT JOIN) so we also detect aggregates
225229
// with persisted events but no view row (crash before initial view write).
226230
// view_version is NULL when the view row is missing.
227-
let stale_aggregates: Vec<(String, Option<i64>, i64)> = sqlx::query_as(&format!(
228-
"SELECT e.aggregate_id, v.version, e.max_seq \
231+
let stale_aggregates: Vec<(String, Option<i64>, i64)> =
232+
sqlx::query_as(AssertSqlSafe(format!(
233+
"SELECT e.aggregate_id, v.version, e.max_seq \
229234
FROM ( \
230235
SELECT aggregate_id, MAX(sequence) as max_seq \
231236
FROM events \
@@ -234,10 +239,10 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
234239
) e \
235240
LEFT JOIN {table} v ON v.view_id = e.aggregate_id \
236241
WHERE v.version IS NULL OR e.max_seq > v.version"
237-
))
238-
.bind(&aggregate_type)
239-
.fetch_all(pool)
240-
.await?;
242+
)))
243+
.bind(&aggregate_type)
244+
.fetch_all(pool)
245+
.await?;
241246

242247
if stale_aggregates.is_empty() {
243248
debug!(target: "cqrs", %aggregate_type, "All views up to date, nothing to replay");
@@ -275,10 +280,12 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
275280

276281
info!(target: "cqrs", %view_id, %table, "Rebuilding view from event history");
277282

278-
sqlx::query(&format!("DELETE FROM {table} WHERE view_id = ?1"))
279-
.bind(&view_id)
280-
.execute(pool)
281-
.await?;
283+
sqlx::query(AssertSqlSafe(format!(
284+
"DELETE FROM {table} WHERE view_id = ?1"
285+
)))
286+
.bind(&view_id)
287+
.execute(pool)
288+
.await?;
282289

283290
self.catch_up().await
284291
}
@@ -293,7 +300,7 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
293300

294301
info!(target: "cqrs", %table, "Rebuilding all views from event history");
295302

296-
sqlx::query(&format!("DELETE FROM {table}"))
303+
sqlx::query(AssertSqlSafe(format!("DELETE FROM {table}")))
297304
.execute(pool)
298305
.await?;
299306

@@ -375,11 +382,11 @@ impl<Entity: EventSourced<Materialized = Table>> Projection<Entity> {
375382
// Write directly with version = max_seq, bypassing the view repo's
376383
// optimistic lock (which expects version + 1 increments). This is
377384
// safe because catch_up runs once at startup before the main loop.
378-
sqlx::query(&format!(
385+
sqlx::query(AssertSqlSafe(format!(
379386
"INSERT INTO {table} (view_id, version, payload) \
380387
VALUES (?1, ?2, ?3) \
381388
ON CONFLICT(view_id) DO UPDATE SET version = ?2, payload = ?3"
382-
))
389+
)))
383390
.bind(view_id)
384391
.bind(max_seq)
385392
.bind(&payload)
@@ -557,10 +564,11 @@ async fn validate_column<Entity: EventSourced>(
557564
) -> Result<(), ProjectionError<Entity>> {
558565
let column_name = column.0;
559566

560-
let columns: Vec<(String,)> =
561-
sqlx::query_as(&format!("SELECT name FROM pragma_table_xinfo('{table}')"))
562-
.fetch_all(pool)
563-
.await?;
567+
let columns: Vec<(String,)> = sqlx::query_as(AssertSqlSafe(format!(
568+
"SELECT name FROM pragma_table_xinfo('{table}')"
569+
)))
570+
.fetch_all(pool)
571+
.await?;
564572

565573
if !columns.iter().any(|(name,)| name == column_name) {
566574
warn!(
@@ -575,15 +583,15 @@ async fn validate_column<Entity: EventSourced>(
575583
});
576584
}
577585

578-
let row_count: (i64,) = sqlx::query_as(&format!("SELECT COUNT(*) FROM {table}"))
586+
let row_count: (i64,) = sqlx::query_as(AssertSqlSafe(format!("SELECT COUNT(*) FROM {table}")))
579587
.fetch_one(pool)
580588
.await?;
581589

582590
if row_count.0 > 0 {
583-
let non_null_count: (i64,) = sqlx::query_as(&format!(
591+
let non_null_count: (i64,) = sqlx::query_as(AssertSqlSafe(format!(
584592
"SELECT COUNT(*) FROM {table}
585593
WHERE {column_name} IS NOT NULL"
586-
))
594+
)))
587595
.fetch_one(pool)
588596
.await?;
589597

crates/sqlite-es/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ serde.workspace = true
1010
serde_json.workspace = true
1111
thiserror.workspace = true
1212
tracing.workspace = true
13-
sqlx = { workspace = true, features = ["sqlite", "runtime-tokio-rustls"] }
14-
chrono = "0.4.44"
13+
sqlx = { workspace = true, features = [
14+
"sqlite",
15+
"runtime-tokio",
16+
"tls-rustls",
17+
] }
18+
chrono = "0.4.45"
1519
tokio = { version = "1.52.3", features = ["rt", "sync"] }
1620

1721
[lints]

crates/sqlite-es/src/event_repository.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use cqrs_es::persist::{
55
};
66
use serde_json::Value;
77
use sqlx::sqlite::SqliteRow;
8-
use sqlx::{Pool, Row, Sqlite};
8+
use sqlx::{AssertSqlSafe, Pool, Row, Sqlite};
9+
use std::sync::Arc;
910

1011
use crate::sql_query::SqlQueryFactory;
1112

@@ -148,7 +149,7 @@ impl SqliteEventRepository {
148149
aggregate_id: &str,
149150
) -> Result<Vec<SerializedEvent>, SqliteAggregateError> {
150151
let query = self.query_factory.select_events();
151-
let rows = sqlx::query(&query)
152+
let rows = sqlx::query(AssertSqlSafe(query))
152153
.bind(A::aggregate_type())
153154
.bind(aggregate_id)
154155
.fetch_all(&self.pool)
@@ -165,7 +166,7 @@ impl SqliteEventRepository {
165166
let query = self.query_factory.get_last_events();
166167
let last_sequence_i64 = i64::try_from(last_sequence)?;
167168

168-
let rows = sqlx::query(&query)
169+
let rows = sqlx::query(AssertSqlSafe(query))
169170
.bind(A::aggregate_type())
170171
.bind(aggregate_id)
171172
.bind(last_sequence_i64)
@@ -180,7 +181,7 @@ impl SqliteEventRepository {
180181
aggregate_id: &str,
181182
) -> Result<Option<SerializedSnapshot>, SqliteAggregateError> {
182183
let query = self.query_factory.select_snapshot();
183-
let row = sqlx::query(&query)
184+
let row = sqlx::query(AssertSqlSafe(query))
184185
.bind(A::aggregate_type())
185186
.bind(aggregate_id)
186187
.fetch_optional(&self.pool)
@@ -193,14 +194,14 @@ impl SqliteEventRepository {
193194
}
194195

195196
async fn insert_events(&self, events: &[SerializedEvent]) -> Result<(), SqliteAggregateError> {
196-
let insert_query = self.query_factory.insert_event();
197+
let insert_query: Arc<str> = self.query_factory.insert_event().into();
197198

198199
let mut tx = self.pool.begin().await?;
199200

200201
for event in events {
201202
let sequence_i64 = i64::try_from(event.sequence)?;
202203

203-
let result = sqlx::query(&insert_query)
204+
let result = sqlx::query(AssertSqlSafe(Arc::clone(&insert_query)))
204205
.bind(&event.aggregate_type)
205206
.bind(&event.aggregate_id)
206207
.bind(sequence_i64)
@@ -235,7 +236,7 @@ impl SqliteEventRepository {
235236

236237
let timestamp = chrono::Utc::now().to_rfc3339();
237238

238-
sqlx::query(&query)
239+
sqlx::query(AssertSqlSafe(query))
239240
.bind(A::aggregate_type())
240241
.bind(aggregate_id)
241242
.bind(last_sequence_i64)
@@ -261,14 +262,14 @@ impl SqliteEventRepository {
261262
tokio::spawn(async move {
262263
let rows = match &aggregate_id {
263264
Some(id) => {
264-
sqlx::query(&query)
265+
sqlx::query(AssertSqlSafe(query))
265266
.bind(&aggregate_type)
266267
.bind(id)
267268
.fetch_all(&pool)
268269
.await
269270
}
270271
None => {
271-
sqlx::query(&query)
272+
sqlx::query(AssertSqlSafe(query))
272273
.bind(&aggregate_type)
273274
.fetch_all(&pool)
274275
.await

crates/sqlite-es/src/view_repository.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use async_trait::async_trait;
22
use cqrs_es::persist::{PersistenceError, ViewContext, ViewRepository};
33
use cqrs_es::{Aggregate, View};
4-
use sqlx::{Pool, Row, Sqlite};
4+
use sqlx::{AssertSqlSafe, Pool, Row, Sqlite};
55
use std::marker::PhantomData;
66

77
use crate::sql_query::SqlQueryFactory;
@@ -101,7 +101,7 @@ where
101101
async fn load(&self, view_id: &str) -> Result<Option<V>, PersistenceError> {
102102
let query = SqlQueryFactory::select_view(&self.view_table);
103103

104-
let row = sqlx::query(&query)
104+
let row = sqlx::query(AssertSqlSafe(query))
105105
.bind(view_id)
106106
.fetch_optional(&self.pool)
107107
.await
@@ -127,7 +127,7 @@ where
127127
) -> Result<Option<(V, ViewContext)>, PersistenceError> {
128128
let query = SqlQueryFactory::select_view(&self.view_table);
129129

130-
let row = sqlx::query(&query)
130+
let row = sqlx::query(AssertSqlSafe(query))
131131
.bind(view_id)
132132
.fetch_optional(&self.pool)
133133
.await
@@ -169,7 +169,7 @@ where
169169
if context.version == 0 {
170170
let insert_query = SqlQueryFactory::insert_view(&self.view_table);
171171

172-
sqlx::query(&insert_query)
172+
sqlx::query(AssertSqlSafe(insert_query))
173173
.bind(&context.view_instance_id)
174174
.bind(new_version)
175175
.bind(&payload)
@@ -179,7 +179,7 @@ where
179179
} else {
180180
let update_query = SqlQueryFactory::update_view(&self.view_table);
181181

182-
let result = sqlx::query(&update_query)
182+
let result = sqlx::query(AssertSqlSafe(update_query))
183183
.bind(new_version)
184184
.bind(&payload)
185185
.bind(&context.view_instance_id)

0 commit comments

Comments
 (0)