diff --git a/minisql/src/type_system.rs b/minisql/src/type_system.rs index 532025f..c0ae728 100644 --- a/minisql/src/type_system.rs +++ b/minisql/src/type_system.rs @@ -15,8 +15,20 @@ pub type Uuid = u64; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum Value { - Number(f64), // TODO: Can't put floats as keys in maps, since they don't implement Eq. What to - // do? + // Note that it doesn't really make sense to compare floats on equality without specifying + // precision. You can ofcourse convert a float to string or to a bytevector and then compare + // equality of those, but that's not the right equality. And ofcourse Rust designers are aware + // of this, so floats don't implement the Eq trait. + // This ofcourse complicates indexing of Number columns. + // + // Either we'd have to design a specific key-value map data-structure where keys are floats, + // s.t. to index with a given float K you also specify a tolerance error so that the resulting + // value set will contain all values whose keys are close to K within that tolerence. This + // seems highly non-trivial. + // + // So we choose to make a distinction between indexable and non-indexable types, and Number is + // not indexable. + Number(f64), Indexable(IndexableValue), }