Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public async Task<CallToolResult> ExecuteAsync(
if (!string.IsNullOrWhiteSpace(select))
{
// Update the context to specify which fields will be returned from the entity.
IEnumerable<string> fieldsReturnedForFind = select.Split(",").ToList();
IEnumerable<string> fieldsReturnedForFind = select.Split(',').Select(field => field.Trim()).ToList();
context.UpdateReturnFields(fieldsReturnedForFind);
}

Expand Down
17 changes: 17 additions & 0 deletions src/Service.Tests/Mcp/ReadRecordsToolMsSqlIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ public async Task ReadRecords_WithSelect_ReturnsSelectedFields()
Assert.IsTrue(firstRecord.TryGetProperty("title", out _), "Expected 'title' field in result.");
}

/// <summary>
/// Reads records with whitespace after a comma in the select clause.
/// </summary>
[TestMethod]
public async Task ReadRecords_WithWhitespaceAfterSelectComma_ReturnsSelectedFields()
{
CallToolResult result = await ExecuteReadAsync("Book", select: "id, title");

AssertSuccess(result, "ReadRecords with whitespace after a select comma should succeed.");

JsonElement root = ParseResultRoot(result);
JsonElement records = GetRecordsArray(root);
JsonElement firstRecord = records[0];
Assert.IsTrue(firstRecord.TryGetProperty("id", out _), "Expected 'id' field in result.");
Assert.IsTrue(firstRecord.TryGetProperty("title", out _), "Expected 'title' field in result.");
}

/// <summary>
/// Reads records with an OData filter expression and verifies filtered results are returned.
/// </summary>
Expand Down
Loading