SqlScriptDOM icon indicating copy to clipboard operation
SqlScriptDOM copied to clipboard

XmlForClause object has wrong FirstTokenIndex value in some cases

Open IVNSTN opened this issue 10 months ago • 0 comments

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

Image

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

IVNSTN avatar Feb 28 '25 08:02 IVNSTN