-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.
Milestone
Description
Summary of the new feature/enhancement
As a scripter who has recently been working with databases quite a bit, it's become a headache to check constantly for [DBNull]::Value. It has a tendency to "leak" outside of my database code, and I need to start checking for DbNull values all over the rest of my code as well.
PowerShell already handles both $null and an empty string in the same manner. Can it also treat [DBNull]::Value as $null for purposes of conditionals?
Here is a contrived example of what I mean,
$myVar = $null
if (-not $myVar) {
# This will run
'MyVar is null'
}
$myVar = ''
if (-not $myVar) {
# This will also run
'MyVar is null'
}
$myVar = [DbNull]::Value
if (-not $myVar) {
# This will not run
'MyVar is null'
}The last case is what I'd like to see changed - I'd like that to be handled in the same way as the first two cases.
mklement0, ConstantineK, michalporeba, RobertRice2, adegutis and 2 more
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.