SqlScriptDOM
SqlScriptDOM copied to clipboard
XmlForClause object has wrong FirstTokenIndex value in some cases
ScriptDom version: 161.9142.1 Compatibility level: 150
Sample code:
SELECT *
FROM dbo.foo
FOR XML PATH(''), ROOT ('x'), TYPE
SET @x = (SELECT *
FROM dbo.foo
FOR XML PATH(''), ROOT ('x'), TYPE);
Here, in the first case everything is ok: XmlForClause.FirstTokenIndex points to the token representing FOR keyword, the first option points to PATH.
But in the second case (FOR XML used in subquery) XmlForClause.FirstTokenIndex has the same value as for the first option and points to the token representing word PATH which is wrong
XmlForClause.FirstTokenIndex should always point to the FOR keyword.
The same issue applies to JsonForClause.
See also token-index related bug-reports: #118, #90, #91