Skip to content

Commit

Permalink
Merge pull request #45 from NeilMacMullen/editkql
Browse files Browse the repository at this point in the history
Editkql
  • Loading branch information
NeilMacMullen authored Jun 30, 2024
2 parents fea1460 + 9354849 commit 1a045f7
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions applications/pskql/PsKqlCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ protected override void EndProcessing()
//index and pad with nulls where necessary
foreach (var p in item.Properties)
{
if (p is PSScriptProperty scr)
{

}
if (badProperties.Contains(p.Name))
continue;
//it's important we check the property type _before_ attempting to access the Value
Expand Down Expand Up @@ -153,12 +157,29 @@ private void AddValue(string columnName, string typeName, object? value, int row
//special-casing for properties of type "object" which we turn into strings for the purpose of querying
if (typeName == TypeNameHelper.TypeName<object>())
{
typeName = TypeNameHelper.TypeName<string>();
value = value?.ToString() ?? string.Empty;
}

if (value != null)
{
WriteDebug($"property '{columnName}' is object so trying to derive type from value");
typeName = value.GetType().ToString();
WriteDebug($"prop {columnName} typeof '{value}' is {typeName}");
if (value is PSObject ps)
{
WriteDebug($"property '{columnName}' is PSObject so trying to derive type from BaseObject");
typeName = ps.BaseObject.GetType().ToString();
WriteDebug($"prop {columnName} baseobj typeof '{ps.BaseObject}' is {typeName}");
value = ps.BaseObject;
}
}
else
{
typeName = TypeNameHelper.TypeName<string>();
value = value?.ToString() ?? string.Empty;
}


}
WriteDebug($"Getting builder for {columnName}");
var colBuilder = GetOrCreateBuilder(columnName, typeName);
colBuilder.AddAt(value, rowIndex);
}
}
}

0 comments on commit 1a045f7

Please sign in to comment.