From bdf87b0bb18783b00841d03bc9ca7de6565e1cf6 Mon Sep 17 00:00:00 2001 From: Nasr Date: Fri, 28 Jun 2024 10:37:59 -0400 Subject: [PATCH 1/2] fix(torii-core): update entity timestamp on update --- crates/torii/core/src/sql.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/torii/core/src/sql.rs b/crates/torii/core/src/sql.rs index d7a692c728..277f2b9221 100644 --- a/crates/torii/core/src/sql.rs +++ b/crates/torii/core/src/sql.rs @@ -169,14 +169,13 @@ impl Sql { let keys_str = felts_sql_string(&keys); let insert_entities = "INSERT INTO entities (id, keys, event_id, executed_at) VALUES (?, \ ?, ?, ?) ON CONFLICT(id) DO UPDATE SET \ - executed_at=EXCLUDED.executed_at, event_id=EXCLUDED.event_id \ + updated_at=CURRENT_TIMESTAMP, executed_at=EXCLUDED.executed_at, event_id=EXCLUDED.event_id \ RETURNING *"; let mut entity_updated: EntityUpdated = sqlx::query_as(insert_entities) .bind(&entity_id) .bind(&keys_str) .bind(event_id) .bind(utc_dt_string_from_timestamp(block_timestamp)) - .fetch_one(&self.pool) .await?; entity_updated.updated_model = Some(entity.clone()); From 158a4ec2b0bad6ac7d5e4633fe3e94dc481ebf21 Mon Sep 17 00:00:00 2001 From: Nasr Date: Fri, 28 Jun 2024 10:39:04 -0400 Subject: [PATCH 2/2] chore --- crates/torii/core/src/sql.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/torii/core/src/sql.rs b/crates/torii/core/src/sql.rs index 277f2b9221..2f972c7c43 100644 --- a/crates/torii/core/src/sql.rs +++ b/crates/torii/core/src/sql.rs @@ -169,13 +169,14 @@ impl Sql { let keys_str = felts_sql_string(&keys); let insert_entities = "INSERT INTO entities (id, keys, event_id, executed_at) VALUES (?, \ ?, ?, ?) ON CONFLICT(id) DO UPDATE SET \ - updated_at=CURRENT_TIMESTAMP, executed_at=EXCLUDED.executed_at, event_id=EXCLUDED.event_id \ - RETURNING *"; + updated_at=CURRENT_TIMESTAMP, executed_at=EXCLUDED.executed_at, \ + event_id=EXCLUDED.event_id RETURNING *"; let mut entity_updated: EntityUpdated = sqlx::query_as(insert_entities) .bind(&entity_id) .bind(&keys_str) .bind(event_id) .bind(utc_dt_string_from_timestamp(block_timestamp)) + .fetch_one(&self.pool) .await?; entity_updated.updated_model = Some(entity.clone());