New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invoke-DbaQuery / Invoke-DbaAsync - Let PSObject handle more than one table #6921
Invoke-DbaQuery / Invoke-DbaAsync - Let PSObject handle more than one table #6921
Conversation
did not forget this, sorry, had a busy few days. will review in a few hours |
Thank you, @andreasjordan and @niphlod ! Will wait for approval 🙇 |
give it a whirl, I added tests . I believe the ones failing are due to other pending changes in development |
Let's forget sp_blitz for the sake of "keeping it simple". Keeping convertto-json as the "formatter", the original version, which does an array of rows (which are arrays themselves), ends up with
I feel the flexibility of PSObject is hurting here, because what you can have (basically the fix I put in) is this instead
which is more akin of what you get with a single resultset, or invoking the two queries separated. What should we make the PSObject look like for results which are not consistent (i.e. two rows have only the property "a" and the next two ones have properties "b" and "c" ) ? Spitting arrays of arrays has the added bonus of "delimiting" what is a single resultset from another one, i.e. we can identify where one starts and ends. Maybe @potatoqualitee, @wsmelton and @FriedrichWeinmann have a type in mind that fits the bill ? tl;dr: I'm fine either way (but this behaviour is new and should be fixed in stone by a regression test when we agree). I feel there are both pros and cons to each one and both implementations are coming from a solid background.... it's just that PSObject is too damn flexible that can accomodate both :D edit:
note by me : if we can't find a way to make both cohexist it sounds a good solution to the problem of "choosing" |
I have thought about it again and hereby propose the new type PSObjectTable. What do you say, @niphlod ? |
yeah, I don't think anything is going to cut it without an additional -As type. I'd go for PSObjectArray. |
Yes, as it is an Array - let's call it an Array. I had the analogy with DataSet, DataTable and DataRow in mind. But I fully agree with Array. I can change the code probably later today. |
OK, updated the code, @niphlod please have a look. |
the array part looks good, but -As PSObject needs to still spits out results from the two resultsets combined (as the version I posted before we embarked on a "let's make the array output optional"). |
Like this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nailed it! thanks for the patience
@niphlod so sorry to bother but it's giving issues with formatting. help? |
…m/andreasjordan/dbatools into InvokeDbaQuery_Improve_AsPSObject
was looking but @andreasjordan beat me to it. if it does fila again hail me. BTW: @potatoqualitee after the last version of invoke-dbaformatter which checks that a correct version of PSSA is available I can't see why yours generates a different output |
Ok, all green now... |
sweet as heck, merging! thanks everyone 🙇 |
Type of Change
Purpose
I want to get the output of
sp_BlitzFirst @ExpertMode = 1
as PSObject, but the procedure returns 7 tables and-As PSObject
only returns the content of the first table.Approach
If there are more than one table, return an array of rows.
Commands to test
There are maybe better approaches, so feedback is highly welcome.