Skip to content

Commit fe338d3

Browse files
committed
Invoke-DbaDbDataMasking - some changes from code review
1 parent ad2ff05 commit fe338d3

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,3 @@ allcommands.ps1
5252
.aider/aider.chat.history.md
5353
.aider/aider.input.history
5454
.aider/aider.llm.history
55-
**/.claude/settings.local.json

private/functions/Convert-DbaMaskingValue.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ function Convert-DbaMaskingValue {
111111
} else {
112112
switch ($DataType.ToLower()) {
113113
{ $_ -in 'bit', 'bool' } {
114-
if ($item -match "^[0-1]$") {
114+
if ($item -match "^[01]$") {
115115
$newValue = "$item"
116-
} elseif ($item -in "True", "true", "TRUE") {
116+
} elseif ($item -eq "true") {
117117
$newValue = "1"
118-
} elseif ($item -in "False", "false", "FALSE") {
118+
} elseif ($item -eq "false") {
119119
$newValue = "0"
120120
} else {
121121
$errorMessage = "Value '$($item)' is not valid BIT or BOOL"

public/Invoke-DbaDbDataMasking.ps1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -957,14 +957,10 @@ function Invoke-DbaDbDataMasking {
957957

958958
# Convert the values so they can used in T-SQL
959959
try {
960-
if ($row.($columnobject.Name) -eq '') {
961-
if ($columnobject.ColumnType -in 'decimal') {
962-
$newvalue = "0.00"
963-
}
964-
$convertedValue = Convert-DbaMaskingValue -Value $newvalue -DataType $columnobject.ColumnType -Nullable:$columnobject.Nullable -EnableException
965-
} else {
966-
$convertedValue = Convert-DbaMaskingValue -Value $newValue -DataType $columnobject.ColumnType -Nullable:$columnobject.Nullable -EnableException
960+
if ($row.($columnobject.Name) -eq '' -and $columnobject.ColumnType -in 'decimal') {
961+
$newvalue = "0.00"
967962
}
963+
$convertedValue = Convert-DbaMaskingValue -Value $newValue -DataType $columnobject.ColumnType -Nullable:$columnobject.Nullable -EnableException
968964

969965
if ($convertedValue.ErrorMessage) {
970966
$maskingErrorFlag = $true

0 commit comments

Comments
 (0)