Skip to content

Commit

Permalink
Add comment on ugly hack
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx committed Jun 26, 2024
1 parent dd7b165 commit 8e64531
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/core/src/sql/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fn check_both(op: OpQuery, lhs: &Typed, rhs: &Typed) -> Result<(), PlanError> {
}
}

/// Patch the type of the field if the type is a `Identity`, `Address` or `Enum`
fn patch_type(lhs: &FieldOp, ty_lhs: &mut Typed, ty_rhs: &Typed) -> Result<(), PlanError> {
if let FieldOp::Field(f) = lhs {
if let Some(ty) = ty_rhs.ty() {
Expand Down Expand Up @@ -179,6 +180,10 @@ fn type_check(of: &QueryFragment<FieldOp>) -> Result<Typed, PlanError> {
OpQuery::Logic(op) => (*op).into(),
};

// TODO: For the cases of `Identity, Address, Enum` we need to resolve the type from the value we are comparing,
// because the type is not lifted when we parse the query on `spacetimedb_vm::ops::parse`.
//
// This is a temporary solution until we have a better way to resolve the type of the field.
patch_type(lhs, &mut ty_lhs, &ty_rhs)?;
patch_type(rhs, &mut ty_rhs, &ty_lhs)?;

Expand Down

0 comments on commit 8e64531

Please sign in to comment.