Skip to content

Commit 8de200a

Browse files
Address code review feedback - fix query cache parameter handling
Co-authored-by: MPCoreDeveloper <37024522+MPCoreDeveloper@users.noreply.github.com>
1 parent 6e2110e commit 8de200a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

SharpCoreDB/Services/SqlParser.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,19 @@ public void Execute(string sql, Dictionary<string, object?> parameters, IWAL? wa
8989

9090
if (this.queryCache != null)
9191
{
92+
// Cache the structure - for parameterized queries, still track cache hits
9293
var cached = this.queryCache.GetOrAdd(cacheKey, key =>
9394
{
9495
var parsedParts = sql.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries);
9596
return new QueryCache.CachedQuery
9697
{
97-
Sql = key,
98+
Sql = cacheKey,
9899
Parts = parsedParts,
99100
CachedAt = DateTime.UtcNow
100101
};
101102
});
102-
parts = cached.Parts;
103+
// Always parse the bound SQL since it contains the actual values
104+
parts = sql.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries);
103105
}
104106
else
105107
{

0 commit comments

Comments
 (0)