DacFx icon indicating copy to clipboard operation
DacFx copied to clipboard

Provide an option in the SqlNNNScriptGenerator classes to preserve comments

Open arvindshmicrosoft opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. Some use cases for the Sql*ScriptGenerator classes are actually for code "pretty printing" / formatting. However, using Sql150ScriptGenerator to re-generate the SQL text when provided with an input TSqlFragment, leads to comments (single-line and multi-line) both being excluded from the output.

Describe the solution you'd like Provide an PreserveComments property in SqlScriptGeneratorOptions with the default being true in the 160 version, and false in the 150 or lower versions for backward compat.

Describe alternatives you've considered Token re-writing: substituting a faux print statement instead of the comment token is a crude workaround. It fails in case the comment is a trailing suffix of a line within a multi-line T-SQL statement.

arvindshmicrosoft avatar Oct 08 '21 22:10 arvindshmicrosoft

Would really appreciate if this issue was fixed, it will help greatly with using scriptdom to fix code issues. thank you.

dmaloo avatar Oct 12 '21 14:10 dmaloo

This fix would be a huge help! Not only for me but many others. Thank you.

tutuhub avatar Feb 09 '22 13:02 tutuhub

Completely agree that we need an option to preserve comments when using the script generator.

DBojsen avatar Sep 01 '22 21:09 DBojsen