Skip to content

Commit 0de561b

Browse files
authored
fix: substring correctly (#130)
### TL;DR Fixed incorrect string slicing in ClickHouse filter parameters for 'gte' and 'lte' conditions. ### What changed? Modified the string slicing length in `addFilterParams` function from `-3` to `-4` for 'gte' and 'lte' suffixes to properly extract the base column name from filter parameters. ### How to test? 1. Execute queries using filters with 'gte' and 'lte' suffixes 2. Verify that the generated SQL queries contain the correct column names 3. Confirm that filter conditions are properly applied to the results ### Why make this change? The previous implementation was incorrectly slicing the column names for 'gte' and 'lte' conditions, which could lead to malformed SQL queries. This fix ensures proper column name extraction and maintains consistency with the filter parameter naming convention.
2 parents 996d70b + 1ab5a4e commit 0de561b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/storage/clickhouse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ func addFilterParams(key, value, query string) string {
493493
suffix := key[len(key)-3:]
494494
switch suffix {
495495
case "gte":
496-
query += fmt.Sprintf(" AND %s >= '%s'", key[:len(key)-3], value)
496+
query += fmt.Sprintf(" AND %s >= '%s'", key[:len(key)-4], value)
497497
case "lte":
498-
query += fmt.Sprintf(" AND %s <= '%s'", key[:len(key)-3], value)
498+
query += fmt.Sprintf(" AND %s <= '%s'", key[:len(key)-4], value)
499499
case "_lt":
500500
query += fmt.Sprintf(" AND %s < '%s'", key[:len(key)-3], value)
501501
case "_gt":

0 commit comments

Comments
 (0)