Skip to content

Commit

Permalink
feat: Update Concat function to accept any type
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Dec 28, 2023
1 parent 9cef9d2 commit d5b1a0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/gitql-ast/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ lazy_static! {
map.insert(
"concat",
Prototype {
parameters: vec![DataType::Text, DataType::Text, DataType::Varargs(Box::new(DataType::Text))],
parameters: vec![DataType::Any, DataType::Any, DataType::Varargs(Box::new(DataType::Any))],
result: DataType::Text
},
);
Expand Down Expand Up @@ -642,7 +642,7 @@ fn text_soundex(inputs: &[Value]) -> Value {
}

fn text_concat(inputs: &[Value]) -> Value {
let text: Vec<String> = inputs.iter().map(|v| v.as_text()).collect();
let text: Vec<String> = inputs.iter().map(|v| v.to_string()).collect();
Value::Text(text.concat())
}

Expand Down
2 changes: 1 addition & 1 deletion docs/function/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ note that all functions names are case-insensitive.
| RIGHT | Text, Integer | Text | Extracts a number of characters from a string (starting from right). |
| TRANSLATE | Text, Text, Text, | Text | Returns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument. |
| SOUNDEX | Text | Text | Returns a four-character code to evaluate the similarity of two expressions. |
| CONCAT | Text, Text, ...Text | Text | Adds two or more strings together. |
| CONCAT | Any, Any, ...Any | Text | Add several string representations of values together together. |
| UNICODE | Text | Integer | Return an integer value (the Unicode value), for the first character of the input expression. |

### String functions samples
Expand Down

0 comments on commit d5b1a0b

Please sign in to comment.