Skip to content

Commit

Permalink
Moved variables to make sure they get cleared in the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sstad committed Feb 5, 2019
1 parent 14d2149 commit e3a71f5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions functions/Invoke-DbaDbDataMasking.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ function Invoke-DbaDbDataMasking {
$stepcounter = $nullmod = 0

foreach ($tableobject in $tables.Tables) {
$uniqueValues = @()
$uniqueValueColumns = @()

if ($tableobject.Name -in $ExcludeTable) {
Write-Message -Level Verbose -Message "Skipping $($tableobject.Name) because it is explicitly excluded"
Expand All @@ -220,8 +222,6 @@ function Invoke-DbaDbDataMasking {

# Check if the table contains unique indexes
if ($tableobject.HasUniqueIndex) {
$uniqueValues = @()
$uniqueValueColumns = @()

# Loop through the rows and generate a unique value for each row
Write-Message -Level Verbose -Message "Generating unique values for $($tableobject.Name)"
Expand Down Expand Up @@ -325,9 +325,6 @@ function Invoke-DbaDbDataMasking {

$newValue = $uniqueValues[$rowNumber].$($columnobject.Name)

# Increase the row number
$rowNumber++

} else {

# make sure max is good
Expand Down Expand Up @@ -569,7 +566,8 @@ function Invoke-DbaDbDataMasking {
Stop-Function -Message "Error updating $($tableobject.Schema).$($tableobject.Name): $errormessage" -Target $updatequery -Continue -ErrorRecord $_
}


# Increase the row number
$rowNumber++
}
try {
$null = $transaction.Commit()
Expand Down

0 comments on commit e3a71f5

Please sign in to comment.