Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion db/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,25 @@ impl SchemaTypeChecking for Schema {
(ValueType::Double, tv @ TypedValue::Double(_)) => Ok(tv),
(ValueType::String, tv @ TypedValue::String(_)) => Ok(tv),
(ValueType::Uuid, tv @ TypedValue::Uuid(_)) => Ok(tv),
(ValueType::Instant, tv @ TypedValue::Instant(_)) => Ok(tv),
(ValueType::Keyword, tv @ TypedValue::Keyword(_)) => Ok(tv),
// Ref coerces a little: we interpret some things depending on the schema as a Ref.
(ValueType::Ref, TypedValue::Long(x)) => Ok(TypedValue::Ref(x)),
(ValueType::Ref, TypedValue::Keyword(ref x)) => self.require_entid(&x).map(|entid| TypedValue::Ref(entid)),

// Otherwise, we have a type mismatch.
(value_type, _) => bail!(ErrorKind::BadEDNValuePair(value.clone(), value_type)),
// Enumerate all of the types here to allow the compiler to help us.
// We don't enumerate all `TypedValue` cases, though: that would multiply this
// collection by 8!
(vt @ ValueType::Boolean, _) |
(vt @ ValueType::Long, _) |
(vt @ ValueType::Double, _) |
(vt @ ValueType::String, _) |
(vt @ ValueType::Uuid, _) |
(vt @ ValueType::Instant, _) |
(vt @ ValueType::Keyword, _) |
(vt @ ValueType::Ref, _)
=> bail!(ErrorKind::BadEDNValuePair(value.clone(), vt)),
}
}
}
Expand Down