Skip to content

Commit

Permalink
tuple diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Jan 31, 2025
1 parent 1df0eaa commit 636a861
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/dojo/types/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl Ty {
}
(Ty::Tuple(t1), Ty::Tuple(t2)) => {
if t1.len() != t2.len() {
Some(Ty::Tuple(t1.clone()))
Some(Ty::Tuple(t2.clone()))
} else {
// Compare each tuple element recursively
let diff_elements: Vec<Ty> =
Expand All @@ -306,21 +306,21 @@ impl Ty {
if a1 == a2 {
None
} else {
Some(Ty::Array(a1.clone()))
Some(Ty::Array(a2.clone()))
}
}
(Ty::ByteArray(b1), Ty::ByteArray(b2)) => {
if b1 == b2 {
None
} else {
Some(Ty::ByteArray(b1.clone()))
Some(Ty::ByteArray(b2.clone()))
}
}
(Ty::Primitive(p1), Ty::Primitive(p2)) => {
if p1 == p2 {
None
} else {
Some(Ty::Primitive(*p1))
Some(Ty::Primitive(*p2))
}
}
// Different types entirely - we cannot diff them
Expand Down
9 changes: 8 additions & 1 deletion crates/torii/sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ impl Sql {
transaction_hash: Felt,
block_timestamp: u64,
) -> Result<()> {
let id = Argument::String(event_id.to_string());
let id = Argument::String(event_id
.to_string());
let keys = Argument::String(felts_to_sql_string(&event.keys));
let data = Argument::String(felts_to_sql_string(&event.data));
let hash = Argument::FieldElement(transaction_hash);
Expand Down Expand Up @@ -908,6 +909,12 @@ fn add_columns_recursive(
let mut new_path = path.to_vec();
new_path.push(idx.to_string());

if let Some(diff) = tuple_diff {
if diff.len() <= idx {
continue;
}
}

let member_diff = if let Some(diff) = tuple_diff {
if let Some((_, m)) = diff.iter().enumerate().find(|(i, _)| *i == idx) {
Some(m)
Expand Down

0 comments on commit 636a861

Please sign in to comment.