SQL Prompt incorrectly expanding *
Matthew_Sontum
Posts: 26 Bronze 1
in SQL Prompt
This is an edge case, but it is reproducable. In some code that I ran the SQL Prompt formatter on recently there was a common table expression that referenced a temporary table, and then another common table expression that referenced the first common table expression. An example would be:
WITH CTE1 AS (
SELECT *, a+b as ab FROM #TempTable), CTE2 AS (
SELECT *, c+d as cd FROM CTE1)
SELECT * FROM CTE2
SQL Prompt formats that as:
SQL Prompt formats that as:
WITH CTE1 AS (SELECT *, a + b AS ab FROM #TempTable),
CTE2 AS (SELECT CTE1.ab, c + d AS cd FROM CTE1)
SELECT CTE2.ab, CTE2.cd FROM CTE2;
Which is a significant problem, since there are many columns in the original #TempTable that are now omitted from the final and intermediary SELECTs
Which is a significant problem, since there are many columns in the original #TempTable that are now omitted from the final and intermediary SELECTs
Tagged:
Comments
I couldn't reproduce it with the default format style in 9.5.15. Please kindly try it again and share your format style file with us if problem persists.
Thanks.
Tianjiao Li | Redgate Software
Have you visited our Help Center?
Tianjiao Li | Redgate Software
Have you visited our Help Center?
Thanks for your patience.
The development team has triaged this issue and recognized this is a bug. However, they are not able to prioritize it at the moment. This doesn't mean it will not be looked at in the future. Here is the reference number SP-7769 should you need an update again.
Our apologies for the inconvenience caused.
Tianjiao Li | Redgate Software
Have you visited our Help Center?
And yes, this has already caused an issue. I commit the code in source control after running it through the formatter, so that formatting changes can be reviewed separately from functional changes in code. If the SQL Prompt formatter is making functional changes this methodology breaks down.
select * into #temp from dbo.tablea
Thank you for your patience with this issue.
The development team have reviewed the bug in a prioritization of open issues and unfortunately they are unable to fix it.
When reviewing bugs the development team take into account the impact it has and the number of users affected and unfortunately we are unable to fix all bugs and have to prioritize fixing the ones that cause the greatest impact.
I'm sorry that this isn't what you want to hear but thank you for your understanding.
Victoria Wiseman | Redgate Software
Have you visited our Help Center?