diff --git a/crates/gitql-ast/src/expression.rs b/crates/gitql-ast/src/expression.rs index d65c170..3d29a75 100644 --- a/crates/gitql-ast/src/expression.rs +++ b/crates/gitql-ast/src/expression.rs @@ -347,8 +347,8 @@ impl Expression for ContainsExpression { ExpressionKind::Contains } - fn expr_type(&self, scope: &Environment) -> DataType { - self.element.expr_type(scope) + fn expr_type(&self, _scope: &Environment) -> DataType { + DataType::Boolean } fn as_any(&self) -> &dyn Any { diff --git a/crates/gitql-std/src/range/mod.rs b/crates/gitql-std/src/range/mod.rs index 61a4acd..aaebb85 100644 --- a/crates/gitql-std/src/range/mod.rs +++ b/crates/gitql-std/src/range/mod.rs @@ -9,6 +9,7 @@ use std::collections::HashMap; pub fn register_std_range_functions(map: &mut HashMap<&'static str, Function>) { map.insert("int4range", int4range); map.insert("daterange", daterange); + map.insert("tsrange", tsrange); } #[inline(always)] @@ -27,6 +28,13 @@ pub fn register_std_range_function_signatures(map: &mut HashMap<&'static str, Si return_type: DataType::Range(Box::new(DataType::Date)), }, ); + map.insert( + "tsrange", + Signature { + parameters: vec![DataType::DateTime, DataType::DateTime], + return_type: DataType::Range(Box::new(DataType::DateTime)), + }, + ); } pub fn int4range(inputs: &[Value]) -> Value { @@ -44,3 +52,11 @@ pub fn daterange(inputs: &[Value]) -> Value { Box::new(inputs[1].clone()), ) } + +pub fn tsrange(inputs: &[Value]) -> Value { + Value::Range( + DataType::DateTime, + Box::new(inputs[0].clone()), + Box::new(inputs[1].clone()), + ) +} diff --git a/docs/functions/range.md b/docs/functions/range.md index 0bb3814..517e49e 100644 --- a/docs/functions/range.md +++ b/docs/functions/range.md @@ -6,6 +6,8 @@ ### Range functions -| Name | Parameters | Return | Description | -| --------- | ---------------- | -------------- | -------------------------------------------------- | -| int4range | Integer, Integer | Range(Integer) | Create a Range of integer type with start and end. | \ No newline at end of file +| Name | Parameters | Return | Description | +| --------- | ------------------ | --------------- | ---------------------------------------------------- | +| INT4RANGE | Integer, Integer | Range(Integer) | Create a Range of integer type with start and end. | +| DATERANGE | Date, Date | Range(Date) | Create a Range of date type with start and end. | +| TSRANGE | DateTime, DateTime | Range(DateTime) | Create a Range of date time type with start and end. | \ No newline at end of file diff --git a/docs/structure/tables.md b/docs/structure/tables.md index bc5d1c3..e02231c 100644 --- a/docs/structure/tables.md +++ b/docs/structure/tables.md @@ -22,18 +22,18 @@ show tables --- -| Name | Type | Description | -| --------------- | ------- | ------------------------ | -| commit_id | Text | Commit id | -| title | Text | Commit title | -| message | Text | Commit full message | -| author_name | Text | Author name | -| author_email | Text | Author email | -| committer_name | Text | Committer name | -| committer_email | Text | Committer email | -| parents_count | Integer | Number of commit parents | -| datetime | Date | Commit date time | -| repo | Text | Repository full path | +| Name | Type | Description | +| --------------- | -------- | ------------------------ | +| commit_id | Text | Commit id | +| title | Text | Commit title | +| message | Text | Commit full message | +| author_name | Text | Author name | +| author_email | Text | Author email | +| committer_name | Text | Committer name | +| committer_email | Text | Committer email | +| parents_count | Integer | Number of commit parents | +| datetime | DateTime | Commit date time | +| repo | Text | Repository full path | ---