Skip to content

Commit

Permalink
Initial work for better edit-kql behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilMacMullen committed Jun 29, 2024
1 parent a03519a commit 487ef6a
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 487ef6a

Please sign in to comment.