Skip to content

Commit 91d98be

Browse files
vkuttypCopilot
andcommitted
Fix ToMarkdownTable to show raw values instead of record type names
C# record types auto-generate ToString() showing 'Text { IsNull = False, Value = 1 }' which overrides the base SqlValue.ToString(). Use AsString() ?? "NULL" instead so markdown output shows clean values like '1', 'true', 'NULL'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ae533c7 commit 91d98be

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/SqlDotnetty.Core/SqlDataTable.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ public string ToMarkdownTable()
3838
var sb = new StringBuilder();
3939
var widths = Columns.Select((c, i) =>
4040
Math.Max(c.Name.Length, Rows.Count > 0
41-
? Rows.Max(r => r[i].ToString().Length)
41+
? Rows.Max(r => CellText(r[i]).Length)
4242
: 0)).ToArray();
4343

44+
static string CellText(SqlValue v) => v.AsString() ?? "NULL";
45+
4446
void Row(IEnumerable<string> cells)
4547
{
4648
sb.Append("| ");
@@ -54,7 +56,7 @@ void Row(IEnumerable<string> cells)
5456
sb.Append("| ");
5557
foreach (var w in widths) sb.Append(new string('-', w)).Append(" | ");
5658
sb.AppendLine();
57-
foreach (var r in Rows) Row(Enumerable.Range(0, ColumnCount).Select(i => r[i].ToString()));
59+
foreach (var r in Rows) Row(Enumerable.Range(0, ColumnCount).Select(i => CellText(r[i])));
5860
return sb.ToString();
5961
}
6062
}

0 commit comments

Comments
 (0)