Skip to content

Commit

Permalink
Fix a subscript out of range error where the tokens advance beyond th…
Browse files Browse the repository at this point in the history
…e end of the string but the function GetNextTokenID returns 0, which then fails within FormatSQL function since there is no member at index 0. It's not clear why this only fails every second time a query is exported but it is the case where if it fails, exporting it next time will not yield the error. Do it 3rd time, then it fails.
  • Loading branch information
bclothier committed Oct 20, 2023
1 parent 0d9ac0a commit 736c33c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Version Control.accda.src/modules/clsSqlFormatter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Private m_varWordCache(1 To 2) As Variant


'---------------------------------------------------------------------------------------
' Procedure : Format
' Procedure : FormatSQL
' Author : Adam Waller
' Date : 4/1/2020
' Purpose : This is the main function used outside the class for SQL formatting.
Expand Down Expand Up @@ -1214,6 +1214,12 @@ End Function
'
Private Function GetNextTokenID(lngCurrentToken As Long, Optional intExceptType As eTokenTypes) As Long
Dim intToken As Integer

If lngCurrentToken + 1 > m_colTokens.Count Then
GetNextTokenID = lngCurrentToken + 1
Exit Function
End If

For intToken = lngCurrentToken + 1 To m_colTokens.Count
If m_colTokens(intToken)(0) <> intExceptType Then
GetNextTokenID = intToken
Expand Down

0 comments on commit 736c33c

Please sign in to comment.