Skip to content

Commit

Permalink
feat: Support overriding LIKE, GLOB and REGEXP for user defined…
Browse files Browse the repository at this point in the history
… types
  • Loading branch information
AmrDeveloper committed Dec 25, 2024
1 parent d14580c commit 64346c5
Show file tree
Hide file tree
Showing 10 changed files with 334 additions and 232 deletions.
132 changes: 103 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ members = [
]

[workspace.dependencies]
gix = { version = "0.68.0", default-features = false }
gix = { version = "0.69.1", default-features = false }
dyn-clone = { version = "1.0.17" }
comfy-table = { version = "7.1.3" }
termcolor = { version = "1.4.1" }
serde_json = { version = "1.0.133" }
serde_json = { version = "1.0.134" }
csv = { version = "1.3.1" }
chrono = { version = "0.4.39" }
regex = { version = "1.11.1" }
Expand Down
24 changes: 24 additions & 0 deletions crates/gitql-ast/src/types/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,30 @@ pub trait DataType: DynClone {
fn can_perform_explicit_cast_op_to(&self) -> Vec<Box<dyn DataType>> {
vec![]
}

/// Return a list of types that it's possible to perform unary `LIKE' operator with
/// between current DataType and any one of them
///
/// No need to define the result type, it always BoolType
fn can_perform_like_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![]
}

/// Return a list of types that it's possible to perform unary `GLOB' operator with
/// between current DataType and any one of them
///
/// No need to define the result type, it always BoolType
fn can_perform_glob_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![]
}

/// Return a list of types that it's possible to perform unary `REGEXP' operator with
/// between current DataType and any one of them
///
/// No need to define the result type, it always BoolType
fn can_perform_regexp_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![]
}
}

impl dyn DataType {
Expand Down
12 changes: 12 additions & 0 deletions crates/gitql-ast/src/types/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ impl DataType for TextType {
fn can_perform_lte_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![Box::new(TextType)]
}

fn can_perform_like_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![Box::new(TextType)]
}

fn can_perform_glob_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![Box::new(TextType)]
}

fn can_perform_regexp_op_with(&self) -> Vec<Box<dyn DataType>> {
vec![Box::new(TextType)]
}
}
1 change: 1 addition & 0 deletions crates/gitql-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ gitql-ast = { path = "../gitql-ast", version = "0.30.0" }
chrono = { workspace = true }
dyn-clone = { workspace = true }
indexmap = { workspace = true }
regex = { workspace = true }
Loading

0 comments on commit 64346c5

Please sign in to comment.