Skip to content

Commit

Permalink
ColumnNames to work with array untyped object
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-joyle committed Aug 19, 2024
1 parent 7f591a3 commit ba4e4cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public static FormulaValue ColumnNames_UO(IRContext irContext, UntypedObjectValu
{
var impl = args[0].Impl;

if (impl.Type is ExternalType externalType && externalType.Kind == ExternalTypeKind.Object)
if (impl.Type is ExternalType externalType && (externalType.Kind == ExternalTypeKind.Object || externalType.Kind == ExternalTypeKind.ArrayAndObject))
{
if (impl.TryGetPropertyNames(out var propertyNames))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public void PadUntypedObject2ColumnNamesTest()

var result = engine.Eval(@"ColumnNames(Index(padTable, 1))");

// would expect not to be an error value
Assert.IsType<ErrorValue>(result);
Assert.IsAssignableFrom<TableValue>(result);
}

private DataTable GetDataTable()
Expand Down Expand Up @@ -588,7 +587,19 @@ public override bool TryGetProperty(string propertyName, out IUntypedObject resu
}

public override bool TryGetPropertyNames(out IEnumerable<string> result)
{
{
if (DataTable != null)
{
result = DataTable.Columns.Cast<DataColumn>().Select(c => c.ColumnName);
return true;
}

if (DataRow != null)
{
result = DataRow.Table.Columns.Cast<DataColumn>().Select(c => c.ColumnName);
return true;
}

result = null;
return false;
}
Expand Down

0 comments on commit ba4e4cf

Please sign in to comment.