Skip to content

Commit

Permalink
fix: quotes in milvus filter (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurasgkadri98 authored Feb 13, 2025
1 parent f7fee62 commit 07d500a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/privatefunctions/milvus/milvus.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// Global variables
var (
CallsBatchSize = 10000
CallsBatchSize = 500
DumpBatchSize = 10000
MilvusConnectionTimeout = 5 * time.Second
MilvusConnectionRetries = 40
Expand Down Expand Up @@ -934,6 +934,13 @@ func createStringFilterExpression(filterType string, filter []string) (filterExp
}
}()

for i := range filter {
// Escape double backslashes in the filter value.
filter[i] = strings.ReplaceAll(filter[i], "\\", "\\\\")
// Escape single quotes in the filter value
filter[i] = strings.ReplaceAll(filter[i], "'", "\\'")
}

filterExpression = fmt.Sprintf("%s in ['%s'", filterType, filter[0])
if len(filter) > 1 {
filterExpression += fmt.Sprintf(", '%s'", strings.Join(filter[1:], "', '"))
Expand Down

0 comments on commit 07d500a

Please sign in to comment.