Skip to content

Feature Request: Improved [DBNull]::Value comparison #10404

@RamblingCookieMonster

Description

@RamblingCookieMonster

Summary of the new feature/enhancement

As a PowerShell user, I expect some (many!) conveniences with regards to comparisons and type conversions. [dbnull]::value has had some improvement recently with #9794 but could use improvements with other comparisons, e.g. [dbnull]::value -gt 10 should not error out, at least from my perspective.

A practical example. Let's say I have a CMDB with dbnull in a few spots I want to do comparisons:

#Example scenario with a function that uses Invoke-Sqlcmd2 to pull data
    Get-XXXXServer | Where-Object{$_.VCNumCPUs -gt 8}
    #Error for every line where VCNumCPU has DBNull value

    #workaround before recent dbnull handling fix
    Get-XXXXServer | Where-Object{[string]$_.VCNumCPUs -and $_.VCNumCPUs -gt 8}

There is precedence for this: $null -gt 10 is $false, and 10 -gt $null is $true

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or more

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions