Skip to content

Commit

Permalink
REPL fix to print blank records (#2236)
Browse files Browse the repository at this point in the history
Fix for a small issue I found while using REPL.
`Table({Value:1}, Blank())`
  • Loading branch information
anderson-joyle authored Feb 28, 2024
1 parent 1064cd8 commit df482e0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/libraries/Microsoft.PowerFx.Repl/Services/StandardFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,25 @@ private string FormatStandardTable(TableValue table, HashSet<string> selectedFie
}

// special treatment for single column table named Value
else if (table.Rows.Count() > 0 &&
table.Rows.First().Value?.Fields.Count() == 1 &&
table.Rows.First().Value?.Fields.First().Name == "Value")
else if (table.Rows.Count() > 0 &&
table.Type.FieldNames.Count() == 1 &&
table.Type.FieldNames.First() == "Value")
{
var separator = string.Empty;
resultString = new StringBuilder("[");
foreach (var row in table.Rows)
{
resultString.Append(separator);
resultString.Append(FormatField(row.Value.Fields.First(), false));

if (row.IsValue)
{
resultString.Append(FormatField(row.Value.Fields.First(), false));
}
else
{
resultString.Append(row.IsError ? row.Error?.Errors?[0].Message : "Blank()");
}

separator = ", ";
}

Expand Down

0 comments on commit df482e0

Please sign in to comment.