Skip to content

Commit a2aed93

Browse files
author
Mario Rocha
committed
Fix filterSql operator precedence in PostgresDbClient
1 parent 6173e9b commit a2aed93

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

extensions/Postgres/Postgres/Internals/PostgresDbClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,13 @@ DO UPDATE SET
416416

417417
// Filtering logic, including filter by similarity
418418
filterSql = filterSql?.Trim().Replace(PostgresSchema.PlaceholdersTags, this._colTags, StringComparison.Ordinal);
419-
if (string.IsNullOrWhiteSpace(filterSql))
420-
{
421-
filterSql = "TRUE";
422-
}
423419

424420
var maxDistance = 1 - minSimilarity;
425-
filterSql += $" AND {this._colEmbedding} <=> @embedding < @maxDistance";
421+
var distanceFilter = $"{this._colEmbedding} <=> @embedding < @maxDistance";
422+
423+
filterSql = string.IsNullOrWhiteSpace(filterSql) ?
424+
distanceFilter :
425+
$"({filterSql}) AND {distanceFilter}";
426426

427427
if (sqlUserValues == null) { sqlUserValues = []; }
428428

0 commit comments

Comments
 (0)