You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is an option -ParseGO which splits a file or query into multiple pieces of code and runs each splitted code once at a time.
The problem is that the split doesn't take into account that GO could be in comments.
Would it be possible add an option to Invoke-SQLCmd2 to find and replace any GO inside a comment (especially those starting with /* and ending with */) by a space before actually splitting ?
The text was updated successfully, but these errors were encountered:
jeffchulg
changed the title
Running with ParseGo also splits if there are GO in comments
Running with ParseGo also splits if there are GO in comments or inside quoted string
Feb 26, 2021
jeffchulg
changed the title
Running with ParseGo also splits if there are GO in comments or inside quoted string
Running with ParseGo also splits if there are GO in comments
Feb 26, 2021
I changed the $GoSplitterRegex definition in line 440
from $GoSplitterRegex = [regex]'(?smi)^[\s]*GO[\s]*$'
to $GoSplitterRegex = [regex]'(?smi)^\s*GO(?:\s+\d+)?\s*$'
Then I added following line just below:
` $GoSanitizerRegex = '(?sm)/*+?^\sgo(?:\s+\d+)?\s$.+?[*]/'
After that I changed the lines starting 493
from
if ($ParseGO) {
Write-Debug -Message "Stripping GOs from source"
$Pieces = $GoSplitterRegex.Split($Query)
}
to
if ($ParseGO) {
Write-Debug -Message "Stripping GOs from source"
$SanitizedQuery = $Query -split $GoSanitizerRegex -join ""
if($SanitizedQuery -ne $Query) {
Write-Debug "Removed some comments with 'GO' inside it"
}
$Pieces = $GoSplitterRegex.Split($SanitizedQuery)
}
Hi,
there is an option
-ParseGO
which splits a file or query into multiple pieces of code and runs each splitted code once at a time.The problem is that the split doesn't take into account that GO could be in comments.
Would it be possible add an option to
Invoke-SQLCmd2
to find and replace any GO inside a comment (especially those starting with/*
and ending with*/
) by a space before actually splitting ?Some links that could help:
The text was updated successfully, but these errors were encountered: