SqlScriptDOM icon indicating copy to clipboard operation
SqlScriptDOM copied to clipboard

IdentifierCasing option enabling upper / lower / pascal-casing of all identifiers in ScriptWriter

Open ondrejtucny opened this issue 2 months ago • 3 comments

Description

Introduced IdentifierCasing option enabling upper / lower / pascal-casing of all identifiers in ScriptWriter. Resolves #177.

SqlScriptGeneratorOptions now supports a new setting IdentifierCasing with the following options:

  • PreserveOriginal — outputs identifiers as-is; this is the default behavior corresponding to the current state (no breaking change)
  • Lowercase — lower-case all identifiers when producing the output
  • Uppercase — upper-case all identifiers when producing the output
  • PascalCase — first character upper, remaining lower

Added unit tests for the various options, including compatibility with KeywordCasing property and ensuring the default state.

Code Changes

ondrejtucny avatar Oct 27 '25 20:10 ondrejtucny

@microsoft-github-policy-service agree company="BoldBrick"

ondrejtucny avatar Oct 27 '25 20:10 ondrejtucny

But wouldn't that be dangerous to change the casing of identifiers if they depend on the collation used by the containing DB?

clement911 avatar Oct 27 '25 21:10 clement911

But wouldn't that be dangerous to change the casing of identifiers if they depend on the collation used by the containing DB?

This is up to the caller (user of ScriptWriter) to decide. Plus, the default is PreserveOriginal. There are cases where canonical normalization of source code is necessary.

ondrejtucny avatar Oct 27 '25 21:10 ondrejtucny