Skip to content

Option to normalize casing of identifiers in the ScriptGenerator #177

@ondrejtucny

Description

@ondrejtucny

SQL Server compares identifiers with respect to the CI/CS, AI/AS setting of the respective database's collation. While accent sensitivity has no effect on the SQL source code, case-sensitivity may have such an effect when the goal is to produce a 'canonical' form of the source code. The locale part of the collation plays no part in this.

Hence, the settings of the ScriptGenerator should be extended with an option to normalize casing of identifiers as follows:

  • PreserveOriginal — outputs identifiers as-is; this shall be 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

A simple ToLowerInvariant() / ToUpperInvariant() should be used.

Question is, whether the ScriptGenerator should support separate settings for instance-level (global) objects versus objects in a database. This would significantly increase the complexity. See also Database identifiers:

The collation of an identifier depends on the level at which it's defined. Identifiers of instance-level objects, such as logins and database names, are assigned the default collation of the instance. Identifiers of objects in a database, such as tables, views, and column names, are assigned the default collation of the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions