Open llzenoll opened 6 years ago
Same for other statements:
DROP AGGREGATE [ IF EXISTS ]
DROP ASSEMBLY [ IF EXISTS ]
DROP DATABASE [ IF EXISTS ]
DROP DEFAULT [ IF EXISTS ]
DROP FUNCTION [ IF EXISTS ]
DROP INDEX [ IF EXISTS ]
DROP PROC [ IF EXISTS ]
DROP PROCEDURE [ IF EXISTS ]
DROP ROLE [ IF EXISTS ]
DROP RULE [ IF EXISTS ]
DROP SCHEMA [ IF EXISTS ]
DROP SECURITY POLICY [ IF EXISTS ]
DROP SEQUENCE [ IF EXISTS ]
DROP SYNONYM [ IF EXISTS ]
DROP TABLE [ IF EXISTS ]
DROP TRIGGER [ IF EXISTS ]
DROP TYPE [ IF EXISTS ]
DROP USER [ IF EXISTS ]
DROP VIEW [ IF EXISTS ]
I would rename this issue "IF EXISTS" qualifier mistaken for "IF" statement
This is really annoying because I have to use the older syntax in order to avoid formatting issues: IF object_id('tempdb..#negs') IS NOT NULL DROP TABLE #negs;
instead of:
DROP TABLE if exists #negs;
I tried using -- [noformat] , -- [\noformat] and -- [minify] ,-- [\minify] tags and they failed to recognize the end tags and made the formatting worse.
The parsing key here might be noting that EXISTS does not have a parenthesis expression after it. therefore it must be the IF EXISTS keyword. We need to differentiate between :
IF Exists ( select * from foo) .... and the drop commands.
@TaoK hi! any chanse for fix?
Are there any plans to fix it
Agree. DROP VIEW IF EXISTS viewName doesn't work
This is my workaround:
--[noformat]
DROP TABLE IF EXISTS Students;
IF 1 = 0 SELECT 1; --[/noformat]
which is I think the minimal amount of boilerplate to allow the rest of the query to autoformat correctly
The tool doesnt recognize drop view if exists as a key word. This issue also causes poor identation for the rest of the document
INPUT
OUTPUT