Skip to content

Commit 0c454d1

Browse files
fix: update clauses
Signed-off-by: Shivanshu Raj Shrivastava <[email protected]>
1 parent 0350f4a commit 0c454d1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/modules/tracefunnel/query.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import (
99
"github.com/SigNoz/signoz/pkg/types/tracefunneltypes"
1010
)
1111

12-
// sanitizeClause adds AND prefix to non-empty clauses
12+
// sanitizeClause adds AND prefix to non-empty clauses if not already present
1313
func sanitizeClause(clause string) string {
1414
if clause == "" {
1515
return ""
1616
}
17+
// Check if clause already starts with AND
18+
if strings.HasPrefix(strings.TrimSpace(clause), "AND") {
19+
return clause
20+
}
1721
return "AND " + clause
1822
}
1923

pkg/query-service/app/traces/v3/query_builder.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ func buildTracesFilterQuery(fs *v3.FilterSet) (string, error) {
193193
}
194194
queryString := strings.Join(conditions, " AND ")
195195

196+
// Don't add AND prefix if the query string is empty or if it's being used in a WHERE clause that already has AND
196197
if len(queryString) > 0 {
197-
queryString = " AND " + queryString
198+
// Only add AND if the query string doesn't already start with AND
199+
if !strings.HasPrefix(strings.TrimSpace(queryString), "AND") {
200+
queryString = " AND " + queryString
201+
}
198202
}
199203
return queryString, nil
200204
}

0 commit comments

Comments
 (0)