GQL
GQL copied to clipboard
Incorrect equals for DateTime and Time
Describe the bug
Incorrect equals for DateTime and Time
To Reproduce
// https://github.com/AmrDeveloper/GQL/blob/master/crates/gitql-ast/src/value.rs
let value = Value::DateTime(1704890191);
let other = Value::DateTime(1704890192);
let ret = value.equals(&other);
assert_eq!(ret, false); // fails
Expected behavior
assert_eq!(ret, false); // ret is false
GQL (please complete the following information):
Version 0.11.0
Screenshots
See: https://github.com/AmrDeveloper/GQL/blob/master/crates/gitql-ast/src/value.rs
Incorrect
pub fn equals(&self, other: &Self) -> bool {
if self.data_type() != other.data_type() {
return false;
}
match self.data_type() {
DataType::Any => true,
DataType::Text => self.as_text() == other.as_text(),
DataType::Integer => self.as_int() == other.as_int(),
DataType::Float => self.as_float() == other.as_float(),
DataType::Boolean => self.as_bool() == other.as_bool(),
DataType::DateTime => self.as_date() == other.as_date(),
DataType::Date => self.as_date() == other.as_date(),
DataType::Time => self.as_date() == other.as_date(),
DataType::Undefined => true,
DataType::Null => true,
_ => false,
}
}
Expected
DataType::DateTime => self.as_date_time() == other.as_date_time(),
DataType::Date => self.as_date() == other.as_date(),
DataType::Time => self.as_time() == other.as_time(),
Hello @craftslab,
Thank you for reporting, i fixed it now and will release it on 0.12.0 this week
Thank you, Amr Hesham
Fixed and released on 0.12.0