File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -842,7 +842,7 @@ function Invoke-DbaDbDataMasking {
842842 $newValue = $null
843843
844844 # Handle static values
845- if ($columnobject.StaticValue ) {
845+ if ($null -ne $ columnobject.StaticValue ) {
846846 $newValue = $columnobject.StaticValue
847847
848848 if ($null -eq $newValue -and -not $columnobject.Nullable ) {
@@ -904,7 +904,7 @@ function Invoke-DbaDbDataMasking {
904904 }
905905
906906 # If we haven't determined a value yet, generate one
907- if ($null -eq $newValue -and -not $columnobject.StaticValue ) {
907+ if ($null -eq $newValue -and $null -eq $columnobject.StaticValue ) {
908908 # make sure min is good
909909 if ($columnobject.MinValue ) {
910910 $min = $columnobject.MinValue
@@ -1149,6 +1149,15 @@ function Invoke-DbaDbDataMasking {
11491149 }
11501150 }
11511151 }
1152+ # Add FilterQuery WHERE clause to restrict which rows are updated
1153+ if ($validAction -and $tableobject.FilterQuery ) {
1154+ $filterParts = ($tableobject.FilterQuery ) -split " WHERE" , 2 , " ignorecase"
1155+ if ($filterParts.Count -gt 1 ) {
1156+ $filterWhereClause = $filterParts [1 ].Trim().TrimEnd(" ;" )
1157+ $query = $query.TrimEnd (" ;" ) + " WHERE $filterWhereClause ;"
1158+ }
1159+ }
1160+
11521161 # Add the query to the rest
11531162 if ($validAction ) {
11541163 $null = $stringBuilder.AppendLine ($query )
You can’t perform that action at this time.
0 commit comments