Skip to content

Invoke-DbaQuery - Document what -As SingleValue really returns - #10727

Merged
potatoqualitee merged 1 commit into
developmentfrom
invoke-dbaquery-singlevalue-help
Sep 22, 2026
Merged

potatoqualitee merged 1 commit into
developmentfrom
invoke-dbaquery-singlevalue-help

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Summary

The help of Invoke-DbaQuery describes -As SingleValue as "the first column of the first row". The code in Invoke-DbaAsync does $ds.Tables[0] | Select-Object -ExpandProperty <first column>, which returns the first column of every row of the first result set. Measured on 2026-09-20 with dbatools 2.9.0 on PowerShell 7.6.3 against SQL Server 2025:

Query Result
SELECT COUNT(*) FROM sys.databases one System.Int32
SELECT name FROM sys.databases (4 rows) System.Object[] with all 4 names, no warning
SELECT DB_NAME(1) AS a, DB_NAME(2) AS b only a, column b dropped, no warning
sp_BlitzFirst @SinceStartup = 1 (4 result sets) first column of every row of the first result set, the other three dropped, no warning
SELECT CAST(NULL AS nvarchar(10)) System.DBNull, not $null
SELECT ... WHERE 1 = 0 $null, no warning

This PR only changes the help text (.PARAMETER As and .OUTPUTS) to say what the command does. No code or test changes. If the behavior itself should change to match the old wording, that is a separate decision.

Test plan

  • Help text only, no code change
  • Get-Help Invoke-DbaQuery -Parameter As shows the new sentence

created by Claude and reviewed by Andreas Jordan

馃 Generated with Claude Code

The help said SingleValue returns "the first column of the first row".
The code expands the first column of every row of the first result
set, so several rows come back as an array, no row returns $null, a
NULL value is System.DBNull, and further columns and result sets are
dropped silently. Measured on 2026-09-20 with dbatools 2.9.0.

(do Invoke-DbaQuery)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@andreasjordan
andreasjordan marked this pull request as ready for review September 20, 2026 09:35

@potatoqualitee potatoqualitee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete help-only patch at this exact head against the actual SingleValue expansion behavior, surrounding source/tests, discussions, parse equivalence, and passing CI. The corrected wording accurately describes all first-column values. No material defects found.

@potatoqualitee

Copy link
Copy Markdown
Member

thank you 馃檹馃徏

@potatoqualitee
potatoqualitee merged commit 2b67215 into development Sep 22, 2026
22 checks passed
@potatoqualitee
potatoqualitee deleted the invoke-dbaquery-singlevalue-help branch September 22, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants