Skip to content

Commit

Permalink
fix: add type_name filter for event log filters
Browse files Browse the repository at this point in the history
To avoid mistaking events for one entity as another type
  • Loading branch information
jrudolph committed Jun 26, 2024
1 parent 0f55df2 commit b107fee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ where
sqlx::query(
"SELECT version, event
FROM event
WHERE entity_id = $1
WHERE entity_id = $1 AND type_name = $2
ORDER BY seq_no ASC",
)
.bind(id)
.bind(E::TYPE_NAME)
.fetch(&**pool)
.map_err(|error| Error::Sqlx("cannot get next event".to_string(), error))
.map(|row| {
Expand Down Expand Up @@ -306,9 +307,10 @@ where
let version = sqlx::query(
"SELECT MAX(version)
FROM event
WHERE entity_id = $1",
WHERE entity_id = $1 AND type_name = $2",
)
.bind(id)
.bind(E::TYPE_NAME)
.fetch_one(&mut *tx)
.await
.map_err(|error| Error::Sqlx("cannot select max version".to_string(), error))
Expand Down

0 comments on commit b107fee

Please sign in to comment.